Skip to content

Instantly share code, notes, and snippets.

@disintegrator
Created December 18, 2020 10:11
Show Gist options
  • Save disintegrator/4088fa4aff9fc3daf7d1891eba76d306 to your computer and use it in GitHub Desktop.
Save disintegrator/4088fa4aff9fc3daf7d1891eba76d306 to your computer and use it in GitHub Desktop.
VS Code snippets
{
"React function component": {
"prefix": "nrf",
"body": [
"import * as React from \"react\";",
"",
"export interface ${1:$TM_FILENAME_BASE}Props {}",
"",
"const ${1:$TM_FILENAME_BASE}: React.FC<${1:$TM_FILENAME_BASE}Props> = props => {",
" return <>{props.children}</>;",
"};",
"",
"export default ${1:$TM_FILENAME_BASE};",
""
]
},
"React component test suite": {
"prefix": "cts",
"body": [
"import * as React from \"react\";",
"",
"import ${1:${TM_FILENAME/(.+?)\\..*/${1}/}} from \"./${1:${TM_FILENAME/(.+?)\\..*/${1}/}}\";",
"",
"describe(\"${1:${TM_FILENAME/(.+?)\\..*/${1}/}}\", () => {",
" it(\"renders without crashing\", () => {",
" $2",
" });",
"});"
]
},
"React component story": {
"prefix": "csf",
"body": [
"import * as React from \"react\";",
"",
"import { ${1:${TM_FILENAME/(.+?)\\..*/$1/}} } from \".\";",
"",
"export default {",
" title: \"${TM_DIRECTORY/^.+\\/(.*)$/${1:/capitalize}/}/${1:${TM_FILENAME/(.+?)\\..*/$1/}}\",",
" component: ${1:${TM_FILENAME/(.+?)\\..*/$1/}},",
"};",
"",
"export const Intro: React.FC = () => {",
" return ${2:<${1:${TM_FILENAME/(.+?)\\..*/$1/}} />};",
"};",
""
],
"description": "React component story"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment