Skip to content

Instantly share code, notes, and snippets.

@eyalcohen4
Last active June 14, 2020 15:00
Show Gist options
  • Save eyalcohen4/c52501e86c0f78ed4c21bb63fee751d5 to your computer and use it in GitHub Desktop.
Save eyalcohen4/c52501e86c0f78ed4c21bb63fee751d5 to your computer and use it in GitHub Desktop.
React TypeScript Component Snippet

Instructions

  • Go to VSCode, click CMD+Shift+P
  • Enter: Preferences: Configure User Snippets
  • Choose typescriptreact.json
  • Copy the "ReactComponent" property from the typescriptreact.json file to your clipboard
  • Paste
  • Enjoy
{
"ReactComponent": {
"prefix": "comp",
"body": [
"import React from 'react';",
"",
"type $1Props = {",
"",
"}",
"const $1: React.FC<$1Props> = ({}: $1Props) => {",
" return <div className='$2' />",
"}",
"",
"export default $1"
],
"description": "react component"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment