Skip to content

Instantly share code, notes, and snippets.

@MRobertEvers
Last active August 20, 2022 15:00
Show Gist options
  • Save MRobertEvers/fbecca751662867d1d38bf6a23eed3fe to your computer and use it in GitHub Desktop.
Save MRobertEvers/fbecca751662867d1d38bf6a23eed3fe to your computer and use it in GitHub Desktop.
React VSCode Snippets

New Component

  "New Component": {
    "prefix": "rfc",
    "body": [
      "interface ${name:${TM_FILENAME_BASE}}Props {}",
      "",
      "export const ${name:${TM_FILENAME_BASE}} = (props: ${name:${TM_FILENAME_BASE}}Props) => { return <div></div> }"
    ]
  }
  "New Component": {
    "prefix": "rfc",
    "body": [
      "interface ${name:${TM_FILENAME_BASE}}Props {}",
      "",
      "export function ${name:${TM_FILENAME_BASE}}(props: ${name:${TM_FILENAME_BASE}}Props) {",
      "\tconst {} = props;",
      "\treturn <div></div>",
      "}"
    ]
  },
  "New Styled Component": {
    "prefix": "rfcs",
    "body": [
      "import styles from './${TM_FILENAME_BASE}.module.css'",
      "interface ${name:${TM_FILENAME_BASE}}Props {}",
      "",
      "export function ${name:${TM_FILENAME_BASE}}(props: ${name:${TM_FILENAME_BASE}}Props) {",
      "\tconst {} = props;",
      "\treturn <div></div>",
      "}"
    ]
  }

Ex:

interface NameProps {}

export const NameColumn = (props: NameProps) => {
  return <div></div>
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment