Skip to content

Instantly share code, notes, and snippets.

@sidola
Created January 5, 2022 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidola/f044a81bc897de012689163ad844580f to your computer and use it in GitHub Desktop.
Save sidola/f044a81bc897de012689163ad844580f to your computer and use it in GitHub Desktop.
TSX Snippets VSCode
{
// 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