Last active
February 3, 2024 21:03
-
-
Save glowiep/6949391f98e902f8299c2ccf4e69a416 to your computer and use it in GitHub Desktop.
React Visual Studio Code JavaScript Snippets for component, useState, useEffect, and useReducer
This file contains 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
{ | |
"React Component": { | |
"prefix": "react", | |
"body": ["import React from \"react\"", "", "function ${1:ComponentName}() {", " return (", " <>", " $2", " </>", " )", "}", "", "export default ${1:ComponentName}"], | |
"description": "React Component" | |
}, | |
"useState Hook": { | |
"prefix": "use", | |
"body": [ | |
"const [$1, set${1/(.)/${1:/upcase}/}] = useState();" | |
], | |
"description": "Creates a useEffect expression" | |
}, | |
"useEffect Hook": { | |
"prefix": "use", | |
"body": [ | |
"useEffect(() -> {", | |
"$1", | |
"}, []);" | |
], | |
"description": "Creates a useEffect expression" | |
}, | |
"useReducer Hook": { | |
"prefix": "use", | |
"body": ["const ${1:INITIAL_STATE} = {", "", "}", "", "function reducer(state, action) {", " switch (action.type) {", " case \"${4:NameMe}\":", " // Do something here", " return", " }", "}", "", "const [${2:state}, ${3:dispatch}] = useReducer(reducer, $1)"], | |
"description": "Creates a useReducer expression" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment