Skip to content

Instantly share code, notes, and snippets.

@stdavis
Created July 20, 2021 18:25
Show Gist options
  • Save stdavis/f4fbb8883121573330bbeaad4c7c115f to your computer and use it in GitHub Desktop.
Save stdavis/f4fbb8883121573330bbeaad4c7c115f to your computer and use it in GitHub Desktop.
react snippets
// REACT - didn't work in javascriptreact.json
"react component": {
"prefix": "comp",
"body": [
"const ${1:ComponentName} = () => {",
" return (",
" <div>$0</div>",
" );",
"};",
"",
"export default ${1:ComponentName};"
],
"description": "create new react functional component"
},
"useEffect": {
"prefix": "ue",
"body": ["React.useEffect(() => {", " $0", "}, [${1:deps}]);"]
},
"useRef": {
"prefix": "ur",
"body": ["const $1 = React.useRef(${2:null});"]
},
"useState": {
"prefix": "us",
"body": ["const [$1, $2] = React.useState($3);"]
},
"useContext": {
"prefix": "uc",
"body": ["const {$2} = React.useContext($1);"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment