-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnippets.json
53 lines (50 loc) · 1.63 KB
/
snippets.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
"redux action": {
"prefix": "ac",
"body": [
"export function $1(value) {",
" return {",
" type: ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g},",
" value",
" }",
"}"
]
},
"redux constant": {
"prefix": "co",
"body": [
"export const ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g} = '${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}'"
]
},
"redux reducer": {
"prefix": "re",
"body": [
"case ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}:",
"return state",
" .set('${1/(set)([A-Z])(.*)/${2:/downcase}$3/}', action.value);"
]
},
"whatchanged": {
"prefix": "whatchanged",
"body": [
"componentWillReceiveProps(nextProps) {",
" const changedProps = _.reduce(this.props, (result, value, key) => (_.isEqual(value, nextProps[key])",
" ? result",
" : result.concat(key)), []);",
"",
" console.group(`${this.constructor.name} CHANGED PROPS`);",
" changedProps.forEach((changedProp) => {",
" console.group(`${changedProp}`);",
" console.group('OLD');",
" console.log(this.props[changedProp]);",
" console.groupEnd();",
" console.group('NEW');",
" console.log(nextProps[changedProp]);",
" console.groupEnd();",
" console.groupEnd();",
" });",
" console.groupEnd();",
"}",
]
}
}