Last active
October 14, 2023 17:44
-
-
Save joel-daros/c4155cee14a5efd38da712416b11a681 to your computer and use it in GitHub Desktop.
VSCode React Typescript Snippets
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
Show hidden 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. | |
"React functional component": { | |
"scope": "typescript,typescriptreact", | |
"prefix": "rfc", | |
"body": [ | |
"import React from \"react\";", | |
"", | |
"export const ${1:${TM_FILENAME_BASE}}: React.FC = () => {", | |
" return <div>${1:${TM_FILENAME_BASE}}</div>;", | |
"};", | |
], | |
"description": "React functional componet", | |
}, | |
"React functional component with props": { | |
"scope": "typescript,typescriptreact", | |
"prefix": "rfcp", | |
"body": [ | |
"import React from \"react\";", | |
"", | |
"type ${1:${TM_FILENAME_BASE}}Props = {", | |
" ${0}", | |
"};", | |
"", | |
"export const ${1:${TM_FILENAME_BASE}}: React.FC<${1:${TM_FILENAME_BASE}}Props> = () => {", | |
" return <div>${1:${TM_FILENAME_BASE}}</div>;", | |
"};", | |
], | |
"description": "React functional componet with props", | |
}, | |
"React functional component with children": { | |
"scope": "typescript,typescriptreact", | |
"prefix": "rfcc", | |
"body": [ | |
"import React from \"react\";", | |
"", | |
"type ${1:${TM_FILENAME_BASE}}Props = {", | |
" ${0}", | |
"};", | |
"", | |
"export const ${1:${TM_FILENAME_BASE}}: React.FC<PropsWithChildren<${1:${TM_FILENAME_BASE}}Props>> = ({ children }) => {", | |
" return <div>{children}</div>;", | |
"};", | |
], | |
"description": "React functional componet with props and children", | |
}, | |
"Complete Test": { | |
"scope": "typescript,typescriptreact", | |
"prefix": "test", | |
"body": [ | |
"describe(\"${1:${TM_FILENAME_BASE}}\", () => {", | |
" it(\"${2:should match the snapshot}\", () => {", | |
" ${0}", | |
" });", | |
"});", | |
], | |
"description": "Complete test snippet", | |
}, | |
"Test Describe": { | |
"scope": "typescript,typescriptreact", | |
"prefix": "desc", | |
"body": [ | |
"describe(\"${1:${TM_FILENAME_BASE}}\", () => {", | |
" ${0}", | |
"});", | |
], | |
"description": "Test describe", | |
}, | |
"Test It": { | |
"scope": "typescript,typescriptreact", | |
"prefix": "it", | |
"body": [ | |
"it(\"${1:should match the snapshot}\", () => {", | |
" ${0}", | |
"});", | |
], | |
"description": "Test it", | |
}, | |
"Console Log": { | |
"scope": "typescript,typescriptreact,javascript,javascriptreact", | |
"prefix": "clg", | |
"body": [ | |
"console.log($0)", | |
], | |
"description": "console.log()", | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment