Skip to content

Instantly share code, notes, and snippets.

@benhorst
Created June 20, 2019 20:44
Show Gist options
  • Save benhorst/c020c5cce74ebb5d964b689563c38a5c to your computer and use it in GitHub Desktop.
Save benhorst/c020c5cce74ebb5d964b689563c38a5c to your computer and use it in GitHub Desktop.
{
// react & redux snippets for vscode
"react_component": {
"prefix": "comp",
"body": [
"import React from 'react';",
"import PropTypes from 'prop-types';",
"",
"const ${1:ComponentName} = ({}) => (",
"\t<div>",
"\t\t$0",
"\t</div>",
");",
""
],
"description": "pls why"
},
"react_stateful": {
"prefix": "comp state",
"body": [
"import React, { useState } from 'react';",
"import PropTypes from 'prop-types';",
"",
"const ${1:ComponentName} = ({}) => {",
"\tconst [${2:stateName}, set${2:stateName}] = useState(${3:initialState});",
"\treturn (",
"\t\t<div>",
"\t\t\t$0",
"\t\t</div>",
"\t);",
"};",
""
]
},
"react_redux": {
"prefix": "comp redux",
"body": [
"import React, { useState } from 'react';",
"import PropTypes from 'prop-types';",
"import { connect } from 'react-redux';",
"",
"const ${1:ComponentName} = ({}) => {",
"\tconst [${2:stateName}, set${2:stateName}] = useState(${3:initialState});",
"\treturn (",
"\t\t<div>",
"\t\t\t$0",
"\t\t</div>",
"\t);",
"};",
"",
"const mapState = () => ({",
"\t",
"});",
"const mapDispatch = {",
"\t",
"}",
"export const Connected${1ComponentName} = connect(",
"\tmapState,",
"\tmapDispatch,",
")($1);",
""
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment