Last active
May 30, 2024 19:18
-
-
Save srph/c3fa180d691ff5285e45b85405a6b0b4 to your computer and use it in GitHub Desktop.
React Component Snippet for VS Code (based on filename, with prop types)
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
{ | |
"React Component": { | |
"prefix": "0rc", | |
"body": [ | |
"import React from 'react';", | |
"", | |
"interface ${TM_FILENAME_BASE}Props {", | |
" name: string;", | |
"}", | |
"", | |
"const ${TM_FILENAME_BASE} = (props: ${TM_FILENAME_BASE}Props) => {", | |
" return (", | |
" <div>", | |
" <h1>Hello, {props.name}</h1>", | |
" </div>", | |
" );", | |
"};", | |
"", | |
"export { ${TM_FILENAME_BASE} };" | |
], | |
"description": "Create a new React component" | |
} | |
} |
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
{ | |
"React Component Barrel": { | |
"prefix": "1rc", | |
"body": [ | |
"export { ${TM_DIRECTORY/^.+\\/(.*)$/$1/} } from './${TM_DIRECTORY/^.+\\/(.*)$/$1/}';", | |
], | |
"description": "Create barrel file for new React component" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment