Skip to content

Instantly share code, notes, and snippets.

@petejodo
Last active November 7, 2018 15:59
Show Gist options
  • Select an option

  • Save petejodo/09ffe45b04bbc86d693e415b36b7ed9f to your computer and use it in GitHub Desktop.

Select an option

Save petejodo/09ffe45b04bbc86d693e415b36b7ed9f to your computer and use it in GitHub Desktop.

Revisions

  1. petejodo revised this gist Nov 7, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions javascript.json
    Original file line number Diff line number Diff line change
    @@ -92,7 +92,7 @@
    "export const ${TM_FILENAME_BASE/(.*)\\..+$/$1/} = createFragmentContainer(${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component, {",
    "\t${1:viewer}: graphql`",
    "\t\tfragment ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} on ${2:Viewer} {",
    "\t\t\t${3: serviceId}",
    "\t\t\t${3:serviceId}",
    "\t\t}",
    "\t`,",
    "});",
    @@ -124,7 +124,7 @@
    "export const ${TM_FILENAME_BASE/(.*)\\..+$/$1/} = createFragmentContainer(${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component, {",
    "\t${1:viewer}: graphql`",
    "\t\tfragment ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} on ${2:Viewer} {",
    "\t\t\t${3: serviceId}",
    "\t\t\t${3:serviceId}",
    "\t\t}",
    "\t`,",
    "});",
  2. petejodo revised this gist Nov 7, 2018. 1 changed file with 0 additions and 14 deletions.
    14 changes: 0 additions & 14 deletions javascript.json
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,4 @@
    {
    // Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
    // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
    // same ids are connected.
    // Example:
    // "Print to console": {
    // "prefix": "log",
    // "body": [
    // "console.log('$1');",
    // "$2"
    // ],
    // "description": "Log output to console"
    // }

    "React Flow Functional Component": {
    "prefix": "rffc",
    "body": [
  3. petejodo created this gist Nov 7, 2018.
    192 changes: 192 additions & 0 deletions javascript.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,192 @@
    {
    // Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
    // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
    // same ids are connected.
    // Example:
    // "Print to console": {
    // "prefix": "log",
    // "body": [
    // "console.log('$1');",
    // "$2"
    // ],
    // "description": "Log output to console"
    // }

    "React Flow Functional Component": {
    "prefix": "rffc",
    "body": [
    "// @flow",
    "",
    "import * as React from 'react';",
    "",
    "type Props = {",
    "\t${1:children: React.Node,}",
    "};",
    "",
    "export function ${TM_FILENAME_BASE/(.*)\\..+$/$1/}(props: Props) {",
    "\t$0",
    "}",
    ""
    ],
    "description": "Create a React Functional Component w/ Flow"
    },

    "React Flow Class Component": {
    "prefix": "rfcc",
    "body": [
    "// @flow",
    "",
    "import * as React from 'react';",
    "",
    "type Props = {",
    "\t${1:children: React.Node,}",
    "};",
    "",
    "export class ${TM_FILENAME_BASE/(.*)\\..+$/$1/} extends React.Component<Props> {",
    "\trender() {",
    "\t\t$0",
    "\t}",
    "}",
    ""
    ],
    "description": "Create a React Class Component w/ Flow"
    },

    "React Flow Stateful Class Component": {
    "prefix": "rfccs",
    "body": [
    "// @flow",
    "",
    "import * as React from 'react';",
    "",
    "type Props = {",
    "\t${1:children: React.Node,}",
    "};",
    "",
    "type State = {",
    "\t${2:toggled: boolean,}",
    "};",
    "",
    "export class ${TM_FILENAME_BASE/(.*)\\..+$/$1/} extends React.Component<Props, State> {",
    "\tconstructor(props: Props) {",
    "\t\tsuper(props);",
    "\t\tthis.state = {",
    "\t\t\t${3:toggled: false,}",
    "\t\t};",
    "\t}",
    "",
    "\trender() {",
    "\t\t$0",
    "\t}",
    "}",
    ""
    ],
    "description": "Create a React Stateful Class Component w/ Flow"
    },

    "React Flow Fragment Container as Functional Component": {
    "prefix": "rffcfc",
    "body": [
    "// @flow",
    "",
    "import type { ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} as ${2:Viewer}Prop } from './__generated__/${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer}.graphql';",
    "",
    "import * as React from 'react';",
    "import { createFragmentContainer, graphql } from 'react-relay';",
    "",
    "type Props = {",
    "\t${1:viewer}: ${2:Viewer}Prop,",
    "};",
    "",
    "export function ${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component(props: Props) {",
    "\t$0",
    "}",
    "",
    "export const ${TM_FILENAME_BASE/(.*)\\..+$/$1/} = createFragmentContainer(${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component, {",
    "\t${1:viewer}: graphql`",
    "\t\tfragment ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} on ${2:Viewer} {",
    "\t\t\t${3: serviceId}",
    "\t\t}",
    "\t`,",
    "});",
    ""
    ],
    "description": "Create a Relay Fragment Container using a React Functional Component w/ Flow"
    },

    "React Flow Fragment Container as Class Component": {
    "prefix": "rfccfc",
    "body": [
    "// @flow",
    "",
    "import type { ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} as ${2:Viewer}Prop } from './__generated__/${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer}.graphql';",
    "",
    "import * as React from 'react';",
    "import { createFragmentContainer, graphql } from 'react-relay';",
    "",
    "type Props = {",
    "\t${1:viewer}: ${2:Viewer}Prop,",
    "};",
    "",
    "export class ${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component extends React.Component<Props> {",
    "\trender() {",
    "\t\t$0",
    "\t}",
    "}",
    "",
    "export const ${TM_FILENAME_BASE/(.*)\\..+$/$1/} = createFragmentContainer(${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component, {",
    "\t${1:viewer}: graphql`",
    "\t\tfragment ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} on ${2:Viewer} {",
    "\t\t\t${3: serviceId}",
    "\t\t}",
    "\t`,",
    "});",
    ""
    ],
    "description": "Create a Relay Fragment Container using a React Class Component w/ Flow"
    },

    "React Flow Fragment Container as Stateful Class Component": {
    "prefix": "rfccsfc",
    "body": [
    "// @flow",
    "",
    "import type { ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} as ${2:Viewer}Prop } from './__generated__/${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer}.graphql';",
    "",
    "import * as React from 'react';",
    "import { createFragmentContainer, graphql } from 'react-relay';",
    "",
    "type Props = {",
    "\t${1:viewer}: ${2:Viewer}Prop,",
    "};",
    "",
    "type State = {",
    "\t${4:toggled: boolean,}",
    "};",
    "",
    "export class ${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component extends React.Component<Props, State> {",
    "\tconstructor(props: Props) {",
    "\t\tsuper(props);",
    "\t\tthis.state = {",
    "\t\t\t${5:toggled: false,}",
    "\t\t};",
    "\t}",
    "",
    "\trender() {",
    "\t\t$0",
    "\t}",
    "}",
    "",
    "export const ${TM_FILENAME_BASE/(.*)\\..+$/$1/} = createFragmentContainer(${TM_FILENAME_BASE/(.*)\\..+$/$1/}Component, {",
    "\t${1:viewer}: graphql`",
    "\t\tfragment ${TM_FILENAME_BASE/(.*)\\..+$/$1/}_${1:viewer} on ${2:Viewer} {",
    "\t\t\t${3:serviceId}",
    "\t\t}",
    "\t`,",
    "});",
    ""
    ],
    "description": "Create a Relay Fragment Container using a React Stateful Class Component w/ Flow"
    },
    }