Skip to content

Instantly share code, notes, and snippets.

@sohamsshah
Last active March 1, 2023 06:54
Show Gist options
  • Save sohamsshah/8f2da94796441817f40aa65e35e79ac0 to your computer and use it in GitHub Desktop.
Save sohamsshah/8f2da94796441817f40aa65e35e79ac0 to your computer and use it in GitHub Desktop.
Custom React Code Snippet for VSCode
{
"reactArrowFunctionComponentWithDisplayName": {
"prefix": "rafcd",
"body": [
"export const ${1:${TM_FILENAME_BASE}} = () => {",
" return (",
" <div>${1:first}</div>",
" )",
"}",
"",
"${1:${TM_FILENAME_BASE}}.displayName = '${1:${TM_FILENAME_BASE}}'",
],
"description": "Creates a React Arrow Function Component with ES7 module system with display name for debugging purposes",
"scope": "typescript,typescriptreact,javascript,javascriptreact"
},
"typescriptReactArrowFunctionComponent": {
"prefix": "tsrafcd",
"body": [
"type Props = {}",
"",
"const ${1:${TM_FILENAME_BASE}} = (props: Props) => {",
" return (",
" <div>${1:first}</div>",
" )",
"}",
"",
"${1:${TM_FILENAME_BASE}}.displayName = '${1:${TM_FILENAME_BASE}}'",
],
"description": "Creates a React Arrow Function Component with ES7 module system and TypeScript interface with display name for debugging purposes",
"scope": "typescript,typescriptreact,javascript,javascriptreact"
},
"typescriptReactFunctionalComponentWithDisplayName": {
"prefix": "tsrfcd",
"body": [
"type Props = {}",
"",
"export default function ${1:${TM_FILENAME_BASE}}({}: Props) {",
" return (",
" <div>${1:first}</div>",
" )",
"}",
"",
"${1:${TM_FILENAME_BASE}}.displayName = '${1:${TM_FILENAME_BASE}}'",
],
"description": "Creates a React Functional Component with ES7 module system and TypeScript interface with display name for debugging purposes",
"scope": "typescript,typescriptreact,javascript,javascriptreact"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment