Created
November 11, 2018 19:46
-
-
Save anthonynichols/2e90d2df76000eaf95ed320ccbe32708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | |
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | |
// is left empty or omitted, the snippet gets applied to all languages. 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": { | |
// "scope": "javascript,typescript", | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", | |
// "$2" | |
// ], | |
// "description": "Log output to console" | |
// } | |
// Typescript | |
"Import module": { | |
"scope": "javascript, javascriptreact, typescript, typescriptreact", | |
"prefix": "import ", | |
"body": "import ${2:*} from '${1:module}';", | |
"description": "Import module" | |
}, | |
// React (JS) | |
"Component Static Prop Types (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "propTypes", | |
"body": "static propTypes = {$0};", | |
"description": "Component Static Prop Types" | |
}, | |
"Component Static Default Props (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "defaultProps", | |
"body": "static defaultProps = {$0};", | |
"description": "Component Static Default Props" | |
}, | |
"Component Static Get Derived State From Props (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "getDerivedStateFromProps", | |
"body": "static getDerivedStateFromProps(${1:nextProps}, ${2:prevState}) {$0}", | |
"description": "Component Static Get Derived State From Props" | |
}, | |
"Component Set State (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "setState", | |
"body": "this.setState($1);$0" | |
}, | |
"Component Constructor (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "constructor", | |
"body": [ | |
"constructor(${1:props}) {", | |
"\tsuper(${1:props});", | |
"", | |
"\t$4", | |
"}" | |
] | |
}, | |
"Component Will Mount (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "componentWillMount", | |
"body": "componentWillMount() {$0}", | |
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidMount` instead." | |
}, | |
"Component Did Mount (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "componentDidMount", | |
"body": "componentDidMount() {$0}" | |
}, | |
"Component Will Receive Props (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "componentWillReceiveProps", | |
"body": "componentWillReceiveProps(${1:nextProps}) {$0}", | |
"description": "DEPRECATION WARNING [v16.3]: Use `static getDerivedStateFromProps` instead." | |
}, | |
"Should Component Update (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "shouldComponentUpdate", | |
"body": "shouldComponentUpdate(${1:nextProps}, ${2:nextState}) {$0}" | |
}, | |
"Component Will Update (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "componentWillUpdate", | |
"body": "componentWillUpdate(${1:nextProps}, ${2:nextState}) {$0}", | |
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidUpdate` instead." | |
}, | |
"Component Did Update (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "componentDidUpdate", | |
"body": "componentDidUpdate(${1:nextProps}, ${2:state}) {$0}" | |
}, | |
"Component Will Unmount (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "componentWillUnmount", | |
"body": "componentWillUnmount() {$0}" | |
}, | |
"Component Did Catch (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "componentDidCatch", | |
"body": "componentDidCatch(${1:error}, ${2:errorInfo}) {$0}" | |
}, | |
"Component Render (JS)": { | |
"scope": "javascriptreact", | |
"prefix": "render", | |
"body": [ | |
"render() {", | |
"\treturn ($0);", | |
"}" | |
] | |
}, | |
// React (TS) | |
"Component Static Default Props (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "defaultProps", | |
"body": "static defaultProps: Partial<${1:${TM_FILENAME_BASE}Props}> = {$0};" | |
}, | |
"Component Static Get Derived State From Props (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "getDerivedStateFromProps", | |
"body": "static getDerivedStateFromProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:prevState}: ${6:${TM_FILENAME_BASE}${5:State}}): Partial<${6:${TM_FILENAME_BASE}${5:State}}> {$0}" | |
}, | |
"Component Set State (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "setState", | |
"body": "this.setState($1);$0" | |
}, | |
"Component Constructor (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "constructor", | |
"body": [ | |
"constructor(${1:props}: ${3:${TM_FILENAME_BASE}${2:Props}}) {", | |
"\tsuper(${1:props});", | |
"", | |
"\t$4", | |
"}" | |
] | |
}, | |
"Component Will Mount (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "componentWillMount", | |
"body": "componentWillMount() {$0}", | |
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidMount` instead." | |
}, | |
"Component Did Mount (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "componentDidMount", | |
"body": "componentDidMount() {$0}" | |
}, | |
"Component Will Receive Props (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "componentWillReceiveProps", | |
"body": "componentWillReceiveProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}) {$0}", | |
"description": "DEPRECATION WARNING [v16.3]: Use `static getDerivedStateFromProps` instead." | |
}, | |
"Should Component Update (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "shouldComponentUpdate", | |
"body": "shouldComponentUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {$0}" | |
}, | |
"Component Will Update (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "componentWillUpdate", | |
"body": "componentWillUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {$0}", | |
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidUpdate` instead." | |
}, | |
"Component Did Update (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "componentDidUpdate", | |
"body": "componentDidUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {$0}" | |
}, | |
"Component Will Unmount (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "componentWillUnmount", | |
"body": "componentWillUnmount() {$0}" | |
}, | |
"Component Did Catch (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "componentDidCatch", | |
"body": "componentDidCatch(${1:error}: Error, ${2:errorInfo}: React.ErrorInfo) {$0}" | |
}, | |
"Component Render (TS)": { | |
"scope": "typescriptreact", | |
"prefix": "render", | |
"body": [ | |
"render() {", | |
"\treturn ($0);", | |
"}" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment