Skip to content

Instantly share code, notes, and snippets.

@LearnWebCode
Created March 11, 2021 22:59
Show Gist options
  • Save LearnWebCode/69704deb790eb913eef90172e87af905 to your computer and use it in GitHub Desktop.
Save LearnWebCode/69704deb790eb913eef90172e87af905 to your computer and use it in GitHub Desktop.
React Visual Studio Code Snippets for component, useEffect, useState, and useImmerReducer
{
"React Component": {
"prefix": "rc",
"body": ["import React, { useEffect } from \"react\"", "", "function ${1:ComponentName}() {", " return (", " <>", " $2", " </>", " )", "}", "", "export default ${1:ComponentName}"],
"description": "React Component"
},
"useEffect": {
"prefix": "ue",
"body": ["useEffect(() => {", " $2", "}, [$1])"],
"description": "useEffect"
},
"useState": {
"prefix": "us",
"body": ["const [$1, set${1/(.*)/${1:/capitalize}/}] = useState($2)"],
"description": "useState"
},
"useImmerReducer": {
"prefix": "uir",
"body": ["const ${1:initialState} = {", "", "}", "", "function reducer(draft, action) {", " switch (action.type) {", " case \"${4:NameMe}\":", " // Do something here", " return", " }", "}", "", "const [${2:state}, ${3:dispatch}] = useImmerReducer(reducer, $1)"],
"description": "useImmerReducer"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment