Last active
February 19, 2016 23:00
-
-
Save tomlagier/6fad58b062651e590ac4 to your computer and use it in GitHub Desktop.
Useful React snippets
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 component": { | |
"prefix": "comp", | |
"body": [ | |
"import * as React from 'react';", | |
"import './${componentName}.scss';", | |
"", | |
"export default class ${componentName} extends React.Component<${props}, ${state}> {", | |
"", | |
"\trender() {", | |
"\t\treturn (", | |
"\t\t\t<div className='${classname}'>", | |
"\t\t\t</div>", | |
"\t\t);", | |
"\t}", | |
"}", | |
"" | |
], | |
"description": "Create a react component" | |
}, | |
"Connected React component": { | |
"prefix": "conn", | |
"body": [ | |
"import * as React from 'react';", | |
"import {connect} from 'react-redux';", | |
"import './${componentName}.scss';", | |
"", | |
"class ${componentName} extends React.Component<${props}, ${state}> {", | |
"", | |
"\trender() {", | |
"\t\treturn (", | |
"\t\t\t<div className='${classname}'>", | |
"\t\t\t</div>", | |
"\t\t);", | |
"\t}", | |
"}", | |
"", | |
"const get${componentName}Props = state => {", | |
"\treturn {", | |
"", | |
"\t}", | |
"}", | |
"", | |
"export default connect(get${componentName}Props)(${componentName});", | |
"" | |
], | |
"description": "Create a connected react component" | |
}, | |
"Index file": { | |
"prefix": "index", | |
"body": [ | |
"import ${componentName} from './${componentName}';", | |
"export default ${componentName};", | |
"" | |
], | |
"description": "Create an index file for a react component" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment