Created
January 5, 2022 09:37
-
-
Save sidola/f044a81bc897de012689163ad844580f to your computer and use it in GitHub Desktop.
TSX Snippets VSCode
This file contains hidden or 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
{ | |
// https://snippet-generator.app/ | |
"React component": { | |
"prefix": "rcomp", | |
"body": [ | |
"type ${1:Component}Props = {", | |
"", | |
"}", | |
"", | |
"export const ${1:Component} = (props: ${1:Component}Props): JSX.Element | null => {", | |
"", | |
" return (", | |
" <div>", | |
" {\"${1:Component}\"}", | |
" </div>", | |
" )", | |
"}" | |
], | |
"description": "" | |
}, | |
"Generic React Component": { | |
"prefix": "grcomp", | |
// Beware, use `function` instead of arrow to disambiguate | |
// <T>, otherwise we get a JSX error. | |
"body": [ | |
"type ${1:Component}Props<T> = {", | |
"", | |
"}", | |
"", | |
"export const ${1:Component} = function<T>(props: ${1:Component}Props<T>): JSX.Element | null {", | |
"", | |
" return (", | |
" <div>", | |
" {\"${1:Component}\"}", | |
" </div>", | |
" )", | |
"}" | |
], | |
"description": "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment