Skip to content

Instantly share code, notes, and snippets.

@georgekrax
Last active November 13, 2020 21:06
Show Gist options
  • Save georgekrax/723d39defcd3ac9241be6412bd5e996a to your computer and use it in GitHub Desktop.
Save georgekrax/723d39defcd3ac9241be6412bd5e996a to your computer and use it in GitHub Desktop.
VS Code Snippets for TypeScript React & Next.js
{
"TS React Dual Export": {
"prefix": "rfac",
"body": [
"import React from \"react\"",
"",
"export type Props = {",
"",
"}",
"",
"export const $TM_FILENAME_BASE: React.FC<Props> = () => {",
"\treturn (",
"\t\t<div>",
"",
"\t\t</div>",
"\t);",
"};",
"",
"export default $TM_FILENAME_BASE;"
],
"description": "Creates a React Arrow Function Component with ES7 module system & default export (custom snippet)"
},
"TS Next.js Component": {
"prefix": "rfacn",
"body": [
"type Props = {",
"",
"}",
"",
"const $TM_FILENAME_BASE: React.FC<Props> = () => {",
"\treturn (",
"\t\t<div>",
"",
"\t\t</div>",
"\t);",
"};",
"",
"export default $TM_FILENAME_BASE;"
],
"description": "Creates a Next.js (React) Arrow Function Component with default export (custom snippet)"
}
}
@georgekrax
Copy link
Author

georgekrax commented Oct 29, 2020

Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body, and description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:

  • $1, $2 for tab stops
  • $0 for the final cursor position
  • ${1:label}, ${2:another} for placeholders

Placeholders with the same ids are connected.

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