-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathjavascript.snippets
156 lines (127 loc) · 2.08 KB
/
javascript.snippets
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#
# React snippets
#
snippet cdm "Component did mount" b
componentDidMount() {
${1}
}$0
endsnippet
snippet cdup "Component did update" b
componentDidUpdate(prevProps, prevState) {
${1}
}$0
endsnippet
snippet cwm "Component will mount" b
componentWillMount() {
${1}
}$0
endsnippet
snippet cwr "Component will receive props" b
componentWillReceiveProps(nextProps) {
${1}
}$0
endsnippet
snippet cwun "Component will unmount" b
componentWillUnmount() {
${1}
}$0
endsnippet
snippet cwu "Component will update" b
componentWillUpdate(nextProps, nextState) {
${1}
}$0
endsnippet
snippet fup "Force update"
forceUpdate(${1:callback})
endsnippet
snippet gdp "Get default props" b
getDefaultProps() {
return {
${1}
}
}$0
endsnippet
snippet gis "Get initial state" b
getInitialState() {
return {
${1}: ${2}
}
}$0
endsnippet
snippet ism "Is mounted"
isMounted()
endsnippet
snippet jsx "Define jsx dom" b
/**
* @jsx React.DOM
*/
import React from 'react';
let ${2:ClassName} = React.createClass({
render() {
return (
${VISUAL}$4
);
}
});
$0
${3:module.exports = $2;}
endsnippet
snippet pt "propTypes" b
propTypes: {
${1}: React.PropTypes.${2:string}
}
endsnippet
snippet rcc "React.createClass" b
let ${1:ClassName} = React.createClass({
render() {
return (
${VISUAL}$2
)
}
})
$0
endsnippet
snippet rcx "Extends React.Component" b
class ${1:ClassName} extends React.Component {
render(){
return (
$2
)
}
}
endsnippet
snippet ren "render"
render() {
return (
${1:<div />}
)
}$0
endsnippet
snippet sst "Set state" b
this.setState({
${1}: ${2}
})$0
endsnippet
snippet scu "Should component update"
shouldComponentUpdate(nextProps, nextState) {
${1}
}$0
endsnippet
snippet props "Get property" i
this.props.${1}
endsnippet
snippet state "Get state" i
this.state.${1}
endsnippet
snippet trp "Transfer props to"
this.transferPropsTo(${VISUAL}$0)
endsnippet
# This snippet will only works if the keyword 'con' is the first word of line
snippet con "Constructor for React.Component" b
constructor(props, context) {
super(props, context)
this.state = {
$1: $2
}
}$0
endsnippet