Skip to content

Instantly share code, notes, and snippets.

@josephshambrook
Last active May 21, 2021 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephshambrook/f1a90848687dbae6b7b9b0eea864f4a9 to your computer and use it in GitHub Desktop.
Save josephshambrook/f1a90848687dbae6b7b9b0eea864f4a9 to your computer and use it in GitHub Desktop.
My VS Code global shortcuts
{
// My VSCode global shortcuts
// Mostly JavaScript stuff, and will add to it gradually
// To save:
// - Go to Preferences > User Snippets
// - Paste the contents of this file
"console.log": {
"scope": "javascript,typescript",
"prefix": "log",
"body": ["console.log('$1', $1);"],
"description": "Log to console with reference"
},
"React Function Component": {
"scope": "javascript,javascriptreact",
"prefix": "rfc",
"body": [
"import React from 'react';",
"",
"const $1 = ({ children }) => {",
" return <div>$2</div>",
"}",
"",
"export default $1;"
],
"description": "Creates a React function component"
},
"React Function Component (TS)": {
"scope": "typescript,typescriptreact",
"prefix": "rfc",
"body": [
"export interface $1Props {",
"\t$3",
"}",
"",
"function $1({ $2 }: $1Props) {",
"\treturn ($4)",
"}",
"",
"export default $1;"
],
"description": "Creates a TS React function component"
},
"React Function Component with children (TS)": {
"scope": "typescript,typescriptreact",
"prefix": "rfc",
"body": [
"export interface $1Props {",
"\tchildren: React.ReactNode;",
"}",
"",
"function $1({ children }: $1Props) {",
"\treturn (",
"\t\t<div>{children}</div>",
"\t)",
"}",
"",
"export default $1;"
],
"description": "Creates a TS React function component"
},
"import": {
"scope": "javascript,typescript",
"prefix": "imp",
"body": "import {$2} from \"$1\";",
"description": "Logical entry of importing modules"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment