-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathreact-ts.json
357 lines (357 loc) Β· 12.4 KB
/
react-ts.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
{
"destructuring of props": {
"prefix": "dp",
"body": [
"const { ${1:name} } = this.props"
]
},
"destructuring of state": {
"prefix": "ds",
"body": [
"const { ${1:name} } = this.state"
]
},
"reactClassCompoment": {
"prefix": "rcc",
"body": "import React, { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t$0\n\t\t\t</div>\n\t\t)\n\t}\n}\n\nexport default ${1}",
"description": "Creates a React component class"
},
"reactJustClassCompoment": {
"prefix": "rcjc",
"body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t$0\n\t\t\t</div>\n\t\t)\n\t}\n}\n",
"description": "Creates a React component class"
},
"reactClassCompomentPropTypes": {
"prefix": "rccp",
"body": "import React, { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t$0\n\t\t\t</div>\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}",
"description": "Creates a React component class with PropTypes"
},
"reactClassCompomentWithMethods": {
"prefix": "rcfc",
"body": "import React, { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t<div>\n\n\t\t\t</div>\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}",
"description": "Creates a React component class with PropTypes and all lifecycle methods"
},
"reactFunctionComponent": {
"prefix": "rfc",
"body": "import React from 'react'\n\nexport const ${TM_FILENAME_BASE} = (props : {}) => {\n\treturn (\n\t\t<div>\n\t\t\t$0\n\t\t</div>\n\t)\n}",
"description": "Creates a React functional component without PropTypes"
},
"reactFunctionComponentWithEmotion": {
"prefix": "rfce",
"body": "import { css } from '@emotion/core'\nimport React from 'react'\n\nexport const ${TM_FILENAME_BASE} = (props: {}) => {\n\treturn (\n\t\t<div css={css``}>\n\t\t\t$0\n\t\t</div>\n\t)\n}",
"description": "Creates a React functional component with emotion import"
},
"classConstructor": {
"prefix": "con",
"body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n",
"description": "Adds a default constructor for the class that contains props as arguments"
},
"classConstructorContext": {
"prefix": "conc",
"body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n",
"description": "Adds a default constructor for the class that contains props and context as arguments"
},
"componentWillMount": {
"prefix": "cwm",
"body": "\ncomponentWillMount () {\n\t$0\n}\n",
"description": "Invoked once, both on the client and server, immediately before the initial rendering occurs"
},
"componentDidMount": {
"prefix": "cdm",
"body": "componentDidMount () {\n\t$0\n}\n",
"description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs."
},
"componentWillReceiveProps": {
"prefix": "cwr",
"body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n",
"description": "Invoked when a component is receiving new props. This method is not called for the initial render."
},
"componentGetDerivedStateFromProps": {
"prefix": "cgd",
"body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n",
"description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates."
},
"shouldComponentUpdate": {
"prefix": "scu",
"body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n",
"description": "Invoked before rendering when new props or state are being received. "
},
"componentWillUpdate": {
"prefix": "cwup",
"body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n",
"description": "Invoked immediately before rendering when new props or state are being received."
},
"componentDidUpdate": {
"prefix": "cdup",
"body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n",
"description": "Invoked immediately after the component's updates are flushed to the DOM."
},
"componentWillUnmount": {
"prefix": "cwun",
"body": "componentWillUnmount () {\n\t$0\n}\n",
"description": "Invoked immediately before a component is unmounted from the DOM."
},
"componentRender": {
"prefix": "ren",
"body": "render () {\n\treturn (\n\t\t<div>\n\t\t\t$0\n\t\t</div>\n\t)\n}",
"description": "When called, it should examine this.props and this.state and return a single child element."
},
"componentSetStateObject": {
"prefix": "sst",
"body": "this.setState($0)",
"description": "Performs a shallow merge of nextState into current state"
},
"componentSetStateFunc": {
"prefix": "ssf",
"body": "this.setState((state, props) => { return { $0 }})\n",
"description": "Performs a shallow merge of nextState into current state"
},
"componentProps": {
"prefix": "tp",
"body": "this.props.$0",
"description": "Access component's props"
},
"componentState": {
"prefix": "ts",
"body": "this.state.$0",
"description": "Access component's state"
},
"propTypes": {
"prefix": "rpt",
"body": "$1.propTypes = {\n\t$2\n}",
"description": "Creates empty propTypes declaration"
},
"propTypeArray": {
"prefix": "pta",
"body": "PropTypes.array,",
"description": "Array prop type"
},
"propTypeArrayRequired": {
"prefix": "ptar",
"body": "PropTypes.array.isRequired,",
"description": "Array prop type required"
},
"propTypeBool": {
"prefix": "ptb",
"body": "PropTypes.bool,",
"description": "Bool prop type"
},
"propTypeBoolRequired": {
"prefix": "ptbr",
"body": "PropTypes.bool.isRequired,",
"description": "Bool prop type required"
},
"propTypeFunc": {
"prefix": "ptf",
"body": "PropTypes.func,",
"description": "Func prop type"
},
"propTypeFuncRequired": {
"prefix": "ptfr",
"body": "PropTypes.func.isRequired,",
"description": "Func prop type required"
},
"propTypeNumber": {
"prefix": "ptn",
"body": "PropTypes.number,",
"description": "Number prop type"
},
"propTypeNumberRequired": {
"prefix": "ptnr",
"body": "PropTypes.number.isRequired,",
"description": "Number prop type required"
},
"propTypeObject": {
"prefix": "pto",
"body": "PropTypes.object,",
"description": "Object prop type"
},
"propTypeObjectRequired": {
"prefix": "ptor",
"body": "PropTypes.object.isRequired,",
"description": "Object prop type required"
},
"propTypeString": {
"prefix": "pts",
"body": "PropTypes.string,",
"description": "String prop type"
},
"propTypeStringRequired": {
"prefix": "ptsr",
"body": "PropTypes.string.isRequired,",
"description": "String prop type required"
},
"propTypeNode": {
"prefix": "ptnd",
"body": "PropTypes.node,",
"description": "Anything that can be rendered: numbers, strings, elements or an array"
},
"propTypeNodeRequired": {
"prefix": "ptndr",
"body": "PropTypes.node.isRequired,",
"description": "Anything that can be rendered: numbers, strings, elements or an array required"
},
"propTypeElement": {
"prefix": "ptel",
"body": "PropTypes.element,",
"description": "React element prop type"
},
"propTypeElementRequired": {
"prefix": "ptelr",
"body": "PropTypes.element.isRequired,",
"description": "React element prop type required"
},
"propTypeInstanceOf": {
"prefix": "pti",
"body": "PropTypes.instanceOf($0),",
"description": "Is an instance of a class prop type"
},
"propTypeInstanceOfRequired": {
"prefix": "ptir",
"body": "PropTypes.instanceOf($0).isRequired,",
"description": "Is an instance of a class prop type required"
},
"propTypeEnum": {
"prefix": "pte",
"body": "PropTypes.oneOf(['$0']),",
"description": "Prop type limited to specific values by treating it as an enum"
},
"propTypeEnumRequired": {
"prefix": "pter",
"body": "PropTypes.oneOf(['$0']).isRequired,",
"description": "Prop type limited to specific values by treating it as an enum required"
},
"propTypeOneOfType": {
"prefix": "ptet",
"body": "PropTypes.oneOfType([\n\t$0\n]),",
"description": "An object that could be one of many types"
},
"propTypeOneOfTypeRequired": {
"prefix": "ptetr",
"body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,",
"description": "An object that could be one of many types required"
},
"propTypeArrayOf": {
"prefix": "ptao",
"body": "PropTypes.arrayOf($0),",
"description": "An array of a certain type"
},
"propTypeArrayOfRequired": {
"prefix": "ptaor",
"body": "PropTypes.arrayOf($0).isRequired,",
"description": "An array of a certain type required"
},
"propTypeObjectOf": {
"prefix": "ptoo",
"body": "PropTypes.objectOf($0),",
"description": "An object with property values of a certain type"
},
"propTypeObjectOfRequired": {
"prefix": "ptoor",
"body": "PropTypes.objectOf($0).isRequired,",
"description": "An object with property values of a certain type required"
},
"propTypeShape": {
"prefix": "ptsh",
"body": "PropTypes.shape({\n\t$0\n}),",
"description": "An object taking on a particular shape"
},
"propTypeShapeRequired": {
"prefix": "ptshr",
"body": "PropTypes.shape({\n\t$0\n}).isRequired,",
"description": "An object taking on a particular shape required"
},
"jsx element": {
"prefix": "j",
"body": "<${1:elementName}>\n\t$0\n</${1}>",
"description": "an element"
},
"jsx element self closed": {
"prefix": "jc",
"body": "<${1:elementName} />",
"description": "an element self closed"
},
"jsx elements map": {
"prefix": "jm",
"body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n</${2}>)}",
"description": "an element self closed"
},
"jsx elements map with return": {
"prefix": "jmr",
"body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n</${2}>\n})}",
"description": "an element self closed"
},
"jsx element wrap selection": {
"prefix": "jsx wrap selection with element",
"body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n</${1}>",
"description": "an element"
},
"useState": {
"prefix": "us",
"body": "const [${0:val}, set${1:setterName}] = useState(${2:defVal})",
"description": "use state hook"
},
"useEffect": {
"prefix": "ue",
"body": [
"useEffect(() => {",
"\t$1",
"}, [${3:dependencies}])$0"
],
"description": "React useEffect() hook"
},
"useEffect with cleanup": {
"prefix": "uec",
"body": [
"useEffect(() => {",
"\t$1",
"\n\treturn () => {",
"\t\t$2",
"\t}",
"}, [${3:dependencies}])$0"
],
"description": "React useEffect() hook with a cleanup function"
},
"createContext": {
"prefix": "cc",
"body": [
"export const $1 = createContext<$2>(",
"\t(null as any) as $2",
")"
],
"description": "creates a react context"
},
"useContext": {
"prefix": "uc",
"body": [
"const $1 = useContext($2)$0"
],
"description": "React useContext() hook"
},
"useRef": {
"prefix": "ur",
"body": [
"const ${1:elName}El = useRef(null)$0"
],
"description": "React useContext() hook"
},
"useCallback": {
"prefix": "ucb",
"body": [
"const ${1:memoizedCallback} = useCallback(",
"\t() => {",
"\t\t${2:doSomething}(${3:a}, ${4:b})",
"\t},",
"\t[${5:a}, ${6:b}],",
")$0"
],
"description": "React useCallback() hook"
},
"useMemo": {
"prefix": "ume",
"body": [
"const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0"
],
"description": "React useMemo() hook"
}
}