Skip to content

Instantly share code, notes, and snippets.

@p208p2002
Created August 27, 2018 08:24
Show Gist options
  • Save p208p2002/158323dee5b3a736c4ec19f37aae3ff3 to your computer and use it in GitHub Desktop.
Save p208p2002/158323dee5b3a736c4ec19f37aae3ff3 to your computer and use it in GitHub Desktop.
{
//
"importProptypes":{
"prefix": "#react_i_prop_types",
"body": ["import PropTypes from 'prop-types';"],
"description": "import propTypes"
},
"propTypes":{
"prefix": "#react_prop_types",
"body": [
"${1:ClassName}.propTypes={",
"",
"}"
],
"description": "struct for propTypes"
},
//redux相關
"actionA":{
"prefix": "#react_action_type_a",
"body": [
"export function ${1:FuncName}(){",
"\treturn{",
"\t\ttype:${2:ActionName}",
"\t}",
"}",
],
"description": "new action(typeA)"
},
"actionB":{
"prefix": "#react_action_type_b",
"body": [
"export function ${1:FuncName}(){",
"\treturn (dispatch)=>{",
"\t\tdispatch(${2:})",
"\t}",
"}",
],
"description": "new action(typeB)"
},
"reducer":{
"prefix": "#react_new_reducer",
"body": [
"import {} from './action.js';",
"",
"const initstate = ()=>{",
"\treturn{};",
"}",
"",
"export default (state=initstate(),action)=>{",
"\tswitch (action.type) {",
"\t\tdefault:",
"\t\t\treturn state;",
"\t}",
"}"
],
"description": "make new reducer"
},
"mapStateToProps":{
"prefix": "#react_map_props",
"body": [
"let mapStateToProps = (state)=>{",
"\treturn{",
"\t\t$0",
"\t}",
"}"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment