Created
April 2, 2018 11:40
-
-
Save Cristy94/ede5f61a42e29ce78196e1b7f32ccb2f to your computer and use it in GitHub Desktop.
React Typescript VSCode snippets for quickly creating components (use shorthand 'rc' or 'rcc')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"React Connected Component": { | |
"prefix": "rcc", | |
"body": [ | |
"import * as React from 'react';\r", | |
"import { connect } from 'react-redux';\r", | |
"\r", | |
"interface IOwnProps {\r", | |
"\r", | |
"}\r", | |
"\r", | |
"interface IStateFromProps {\r", | |
"\r", | |
"}\r", | |
"\r", | |
"type IProps = IOwnProps & IStateFromProps;\r", | |
"\r", | |
"const mapStateToProps = (state: IState): IStateFromProps => ({\r", | |
"\r", | |
"});\r", | |
"\r", | |
"class ${1:Component} extends React.Component<IProps> {\r", | |
"\r", | |
" public render(): JSX.Element {\r", | |
" return <div>\r", | |
" Component content\r", | |
" </div>;\r", | |
" }\r", | |
"}\r", | |
"\r", | |
"export default connect(mapStateToProps)(${1:Component});" | |
], | |
"description": "React connected component with own props and props from state." | |
}, | |
"React Component": { | |
"prefix": "rc", | |
"body": [ | |
"import * as React from 'react';\r", | |
"\r", | |
"interface IProps {\r", | |
"\r", | |
"}\r", | |
"\r", | |
"export class ${1:Component} extends React.Component<IProps> {\r", | |
"\r", | |
" public render(): JSX.Element {\r", | |
" return <div>\r", | |
" Component content\r", | |
" </div>;\r", | |
" }\r", | |
"}\r", | |
"" | |
], | |
"description": "React component with own props." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment