Skip to content

Instantly share code, notes, and snippets.

@vtsatskin
Last active February 27, 2019 17:43
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 vtsatskin/92d9a71ba0e39eee1abd47870bef96dd to your computer and use it in GitHub Desktop.
Save vtsatskin/92d9a71ba0e39eee1abd47870bef96dd to your computer and use it in GitHub Desktop.
VS Code snippet for creating a React PureComponent in TypeScript
{
/*
// Place your snippets for TypeScript React 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, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
"React Component": {
"prefix": "rcomp",
"body": [
"import * as React from \"react\";",
"",
"type Props = {};",
"",
"class ${1:Component} extends React.PureComponent<Props> {",
" render() {",
" return null;",
" }",
"}",
"",
"export default ${1:Component};"
]
},
"Jest React": {
"prefix": "jcomp",
"body": [
"import * as React from \"react\";",
"import { shallow } from \"enzyme\";",
"",
"describe(${1:Component}, () => {",
" it(\"should pass\", () => {",
" const wrapper = shallow(<${1:Component} />);",
" expect(wrapper).toMatchSnapshot();",
" });",
"});"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment