Skip to content

Instantly share code, notes, and snippets.

@lucianomlima
Last active April 18, 2018 03:10
Show Gist options
  • Select an option

  • Save lucianomlima/ad1d16a92841a60c0a257047cd1b55e2 to your computer and use it in GitHub Desktop.

Select an option

Save lucianomlima/ad1d16a92841a60c0a257047cd1b55e2 to your computer and use it in GitHub Desktop.

Revisions

  1. lucianomlima revised this gist Apr 18, 2018. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions snippets.cson
    Original file line number Diff line number Diff line change
    @@ -54,18 +54,18 @@

    "React: stateless component":
    prefix: "rcs"
    body: "import React from \'react\';\n\nconst $1 = (${2:props}) => {\n\treturn (\n\t\t$3\n\t);\n}\n\nexport default ${1};\n"
    body: "import React from \'react\';\n\nconst $1 = ${2:props} => (\n\t$3\n);\n\nexport default ${1};\n"

    "React: local stateless component":
    prefix: "rcsl"
    body: "const $1 = (${2:props}) => {\n\treturn (\n\t\t$3\n\t);\n}\n"
    body: "const $1 = ${2:props} => (\n\t$3\n);\n"

    "React: local component function":
    prefix: "rcf"
    "React: component method":
    prefix: "rcm"
    body: "${1:_methodName} ($2) {\n\t$3\n}"

    "React: local component binded function":
    prefix: "rcbf"
    "React: component binded method":
    prefix: "rcbm"
    body: "${1:_methodName} = ($2) => {\n\t$3\n}"

    "React: this.props.":
  2. lucianomlima revised this gist Apr 18, 2018. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion snippets.cson
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    body: "import ${1} from './${1}';"

    "React: constructor":
    prefix: "constructor"
    prefix: "construct"
    body: "constructor(props) {\n\tsuper(props);\n\t${1}\n}"

    "React: componentDidMount() { ... }":
    @@ -36,6 +36,18 @@
    prefix: "scup"
    body: "shouldComponentUpdate(nextProps, nextState) {\n\t${1}\n}"

    "React: componentDidCatch(e, i) { ... }":
    prefix: "cdc"
    body: "componentDidCatch(error, info) {\n\t${1}\n}"

    "React: getDerivedStateFromProps(np, ps) { ... }":
    prefix: "gdsfp"
    body: "getDerivedStateFromProps(nextProps, prevState) {\n\t${1}\n}"

    "React: getSnapshotBeforeUpdate(pp, ps) { ... }":
    prefix: "gsbu"
    body: "getSnapshotBeforeUpdate(prevProps, prevState) {\n\t${1}\n}"

    "React: class skeleton":
    prefix: "rcc"
    body: "import React from \'react\';\n\nclass $1 extends React.Component {\n\trender() {\n\t\treturn (\n\t\t\t$2\n\t\t);\n\t}\n}\n\nexport default ${1};"
  3. lucianomlima revised this gist Apr 7, 2018. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions snippets.cson
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,13 @@
    {
    ".source.js":
    "React: import component":
    prefix: "li"
    body: "import ${1} from './${1}';"

    "React: constructor":
    prefix: "constructor"
    body: "constructor(props) {\n\tsuper(props);\n\t${1}\n}"

    "React: componentDidMount() { ... }":
    prefix: "cdm"
    body: "componentDidMount() {\n\t${1}\n}"
  4. lucianomlima revised this gist Apr 7, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion snippets.cson
    Original file line number Diff line number Diff line change
    @@ -52,15 +52,23 @@
    prefix: "props"
    body: "this.props.${1}"

    "React: const { p } this.props":
    prefix: "cprops"
    body: "const { $1 } = this.props;"

    "React: this.state.":
    prefix: "state"
    body: "this.state.${1}"

    "React: const { s } this.state":
    prefix: "cstate"
    body: "const { $1 } = this.state;"

    "React: this.state = { ... }":
    prefix: "is"
    body: "this.state = {\n\t${1}: ${2}\n}"

    "React: setState({ ... })":
    prefix: "sst"
    body: "this.setState({\n\t${1}: ${2}\n});"
    body: "this.setState({ ${1}: ${2} });"
    }
  5. lucianomlima created this gist Jul 4, 2017.
    66 changes: 66 additions & 0 deletions snippets.cson
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    {
    ".source.js":
    "React: componentDidMount() { ... }":
    prefix: "cdm"
    body: "componentDidMount() {\n\t${1}\n}"

    "React: componentDidUpdate(pp, ps) { ... }":
    prefix: "cdup"
    body: "componentDidUpdate(prevProps, prevState) {\n\t${1}\n}"

    "React: componentWillMount() { ... }":
    prefix: "cwm"
    body: "componentWillMount() {\n\t${1}\n}"

    "React: componentWillReceiveProps(np) { ... }":
    prefix: "cwrp"
    body: "componentWillReceiveProps(nextProps) {\n\t${1}\n}"

    "React: componentWillUnmount() { ... }":
    prefix: "cwun"
    body: "componentWillUnmount() {\n\t${1}\n}"

    "React: componentWillUpdate(np, ns) { ... }":
    prefix: "cwup"
    body: "componentWillUpdate(nextProps, nextState) {\n\t${1}\n}"

    "React: shouldComponentUpdate(np, ns) { ... }":
    prefix: "scup"
    body: "shouldComponentUpdate(nextProps, nextState) {\n\t${1}\n}"

    "React: class skeleton":
    prefix: "rcc"
    body: "import React from \'react\';\n\nclass $1 extends React.Component {\n\trender() {\n\t\treturn (\n\t\t\t$2\n\t\t);\n\t}\n}\n\nexport default ${1};"

    "React: stateless component":
    prefix: "rcs"
    body: "import React from \'react\';\n\nconst $1 = (${2:props}) => {\n\treturn (\n\t\t$3\n\t);\n}\n\nexport default ${1};\n"

    "React: local stateless component":
    prefix: "rcsl"
    body: "const $1 = (${2:props}) => {\n\treturn (\n\t\t$3\n\t);\n}\n"

    "React: local component function":
    prefix: "rcf"
    body: "${1:_methodName} ($2) {\n\t$3\n}"

    "React: local component binded function":
    prefix: "rcbf"
    body: "${1:_methodName} = ($2) => {\n\t$3\n}"

    "React: this.props.":
    prefix: "props"
    body: "this.props.${1}"

    "React: this.state.":
    prefix: "state"
    body: "this.state.${1}"

    "React: this.state = { ... }":
    prefix: "is"
    body: "this.state = {\n\t${1}: ${2}\n}"

    "React: setState({ ... })":
    prefix: "sst"
    body: "this.setState({\n\t${1}: ${2}\n});"
    }