-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact.code-snippets
More file actions
177 lines (177 loc) · 5.13 KB
/
react.code-snippets
File metadata and controls
177 lines (177 loc) · 5.13 KB
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
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript,typescriptreact,javascriptreact",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"method": {
"scope": "javascript,typescript,typescriptreact,javascriptreact",
"prefix": "met",
"body": [
"${1} = (${2}) => {",
"\t${0}",
"};",
""
],
"description": "Creates a method inside a class in ES7 syntax"
},
"map": {
"scope": "javascript,typescript,typescriptreact,javascriptreact",
"prefix": "map",
"body": [
"${1}.map((${2}) => ${3})",
],
"description": "Creates a forEach statement in ES7 syntax"
},
"anonymousFunction": {
"scope": "javascript,typescript,typescriptreact,javascriptreact",
"prefix": "arfl",
"body": [
"(${1}) => {",
"\t${2}",
"}",
""
],
"description": "Creates an anonymous function in ES7 syntax"
},
"arrowFunction": {
"scope": "javascript,typescript,typescriptreact,javascriptreact",
"prefix": "arf",
"body": [
"(${1}) => ${2}"
],
"description": "Creates an anonymous function in ES7 syntax"
},
"namedFunction": {
"scope": "javascript,typescript,typescriptreact,javascriptreact",
"prefix": "fn",
"body": [
"const ${1} = (${2}) => {",
"\t${3}",
"}",
""
],
"description": "Creates a named function in ES7 syntax"
},
"destructingObject": {
"prefix": "dob",
"body": "const {${1}} = ${2}",
"description": "Creates and assigns a local variable using object destructing"
},
"destructingArray": {
"prefix": "dar",
"body": "const [${1}] = ${2}",
"description": "Creates and assigns a local variable using array destructing"
},
"setInterval": {
"prefix": "sti",
"body": [
"setInterval(() => {",
"\t${2}",
"}, ${0});",
""
],
"description": "Executes the given function at specified intervals in ES7 syntax"
},
"setTimeOut": {
"prefix": "sto",
"body": [
"setTimeout(() => {",
"\t${2}",
"}, ${1});",
""
],
"description": "Executes the given function after the specified delay in ES7 syntax"
},
"promise": {
"prefix": "prom",
"body": [
"return new Promise((resolve, reject) => {",
"\t${1}",
"});",
""
],
"description": "Creates and returns a new Promise in the standard ES7 syntax"
},
"consoleAssert": {
"prefix": "cas",
"body": "console.assert(${1}, ${2});",
"description": "If the specified expression is false, the message is written to the console along with a stack trace"
},
"consoleLog": {
"prefix": "clg",
"body": "console.log(${1});",
"description": "Displays a message in the console"
},
"consoleTrace": {
"prefix": "ctr",
"body": "console.trace(${1});",
"description": "Prints a stack trace from the point where the method was called"
},
"consoleLogObject": {
"prefix": "clo",
"body": "console.log('${1}', ${1});",
"description": "Logs property with name."
},
"consoleTime": {
"prefix": "ctm",
"body": "console.time('${1}');",
"description": "Console time wrapper"
},
"consoleTimeEnd": {
"prefix": "cte",
"body": "console.timeEnd('${1}');",
"description": "Console time end wrapper"
},
"consoleWarn": {
"prefix": "cwa",
"body": "console.warn(${1});",
"description": "Displays a message in the console but also displays a yellow warning icon along with the logged message"
},
"consoleInfo": {
"prefix": "cin",
"body": "console.info(${1});",
"description": "Displays a message in the console but also displays a blue information icon along with the logged message"
},
"reactArrowFunctionExportComponentTS": {
"scope": "typescript,typescriptreact",
"prefix": "rfc",
"body": [
"import React from 'react';",
"",
"export interface ${TM_FILENAME_BASE}Props {",
"\t${2}",
"}",
"",
"export const ${TM_FILENAME_BASE} = ({${3}}: ${TM_FILENAME_BASE}) => {",
"\treturn (",
"\t\t<>",
"\t\t\t$0",
"\t\t</>",
"\t);",
"}",
""
],
"description": "Creates a React Arrow Function Component with ES7 module system"
},
"importExportdefault": {
"prefix": "impexp",
"body": [
"import ${TM_DIRECTORY/^.+\\/(.*)$/$1/} from './${TM_DIRECTORY/^.+\\/(.*)$/$1/}';",
"export default ${TM_DIRECTORY/^.+\\/(.*)$/$1/};",
""
],
"description": "Imports and exports"
},
}