Skip to content

Instantly share code, notes, and snippets.

@ratbeard
Created January 24, 2019 22:51
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 ratbeard/ef8daf56110d7e131d4bf29fe4125dcf to your computer and use it in GitHub Desktop.
Save ratbeard/ef8daf56110d7e131d4bf29fe4125dcf to your computer and use it in GitHub Desktop.
{
"React component": {
"prefix": "com",
"body": [
"import React, { Component } from 'react';",
"",
"interface Props {",
" $3",
"}",
"",
"export class ${1} extends Component<Props> {",
" render() {",
" const {} = this.props;",
" ",
" return (",
" <div>",
" ${2:$1}",
" </div>",
" );",
" }",
"}",
""
],
"description": "Create a React Component with typescript."
},
"React component with state": {
"prefix": "coms",
"body": [
"import React, { Component } from 'react';",
"",
"interface Props {",
" $3",
"}",
"",
"const initialState = {",
" $4",
"}",
"",
"export class ${1} extends Component<Props, typeof initialState> {",
" state = initialState;",
"",
" render() {",
" const {} = this.props;",
"",
" return (",
" <div>",
" ${2:$1}",
" </div>",
" );",
" }",
"}",
""
],
"description": "Create a React Component with initialState with typescript."
},
"Destructure this.props": {
"prefix": "pr",
"body": [
"const { $1 } = this.props;"
],
"description": "Destructure this.props"
},
"Destructure this.state": {
"prefix": "st",
"body": [
"const { $1 } = this.state;"
],
"description": "Destructure this.state"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment