Skip to content

Instantly share code, notes, and snippets.

@sreetamdas
Created June 10, 2020 07:53
Show Gist options
  • Save sreetamdas/5cafa22f6b53977feef642c34533796e to your computer and use it in GitHub Desktop.
Save sreetamdas/5cafa22f6b53977feef642c34533796e to your computer and use it in GitHub Desktop.
Snippets for React Hooks
{
"React Functional Component": {
"prefix": "rfc",
"body": [
"import React from \"react\";",
"",
"const $TM_FILENAME_BASE = () => {",
"",
"\treturn (",
"\t\t${2:}",
"\t)",
"}",
"",
"export { $TM_FILENAME_BASE }"
],
"description": "React Functional Component"
},
"useState Hook": {
"prefix": "ush",
"body": [
"const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState($2);$0"
],
"description": "useState Hook"
},
"useEffect Hook": {
"prefix": "ueh",
"body": [
"useEffect(() => {",
"\t$1",
// "\n\treturn cleanUp = () => {",
// "\t\t$2",
// "\t}",
"}, [${3}]);$0"
],
"description": "useEffect Hook"
},
"useLayoutEffect Hook": {
"prefix": "uleh",
"body": [
"useLayoutEffect(() => {",
"\t$1",
// "\n\treturn cleanUp = () => {",
// "\t\t$2",
// "\t}",
"}, [${3}]);$0"
],
"description": "useLayoutEffect Hook"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment