Skip to content

Instantly share code, notes, and snippets.

@tomlagier
Last active February 19, 2016 23:00
Show Gist options
  • Save tomlagier/6fad58b062651e590ac4 to your computer and use it in GitHub Desktop.
Save tomlagier/6fad58b062651e590ac4 to your computer and use it in GitHub Desktop.
Useful React snippets
{
"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