-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypescriptreact.json
114 lines (114 loc) · 2.98 KB
/
typescriptreact.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
{
"iife": {
"prefix": "iife",
"body": ["(() => {", "", "})()"],
"description": "Immediatly Invoked Function Expression"
},
"1-arity function": {
"prefix": "function-arity-1",
"body": ["const ${1:functionName} = (): ${2:ReturnType} => "],
"description": "Function of arity 1"
},
"React Component": {
"prefix": "react-component",
"body": [
"import React from \"react\";",
"",
"const Component: React.FunctionComponent = () => <div>",
"",
"</div>;",
"",
"export default Component;",
""
],
"description": "React component with no props"
},
"React Component with props": {
"prefix": "react-component-props",
"body": [
"import React from \"react\";",
"",
"type Props = {",
" children: React.ReactNode;",
"};",
"",
"const Component: React.FunctionComponent<Props> = ({ children }) => (",
" <div>{children}</div>",
");",
"",
"export default Component;",
""
],
"description": "React component with props, including children props."
},
"React Compound Component": {
"prefix": "react-compound-component",
"body": [
"import React from \"react\";",
"import SubComponent from \"./SubComponent\";",
"",
"type Props = {",
" children: React.ReactNode;",
"};",
"",
"const MainComponent: React.FunctionComponent<Props> = ({ children }) => (",
" <div>{children}</div>",
");",
"",
"const Component = MainComponent as React.FunctionComponent<Props> & {",
" SubComponent: typeof SubComponent;",
"};",
"",
"Component.SubComponent = SubComponent;",
"",
"export default Component;",
""
],
"description": "React compound component"
},
"React render props": {
"prefix": "react-render-props",
"body": ["${1:render}: () => React.ReactElement;"],
"description": "React render props"
},
"React children": {
"prefix": "react-children",
"body": ["children: React.ReactNode;"],
"description": "React children"
},
"React use state": {
"prefix": "react-use-state",
"body": ["const [state, setState] = React.useState<number>(0);"],
"description": "React use state hook"
},
"Jest describe": {
"prefix": "jest-describe",
"body": ["describe(\"\", () => {", " ", "});"],
"description": "Jest describe"
},
"Jest test": {
"prefix": "jest-test",
"body": [
"test(\"\", () => {",
" // Given",
" ",
" // When",
" const actual = ${1:functionUnderTest}();",
" ",
" // Then",
" const expected: ${2:number} = 0;",
" expect(actual).toEqual(expected);",
"});"
],
"description": "Jest test"
},
"Jest short test": {
"prefix": "jest-test-short",
"body": [
"test(\"\", () => {",
" expect(${1:functionUnderTest}()).toEqual(${2:expected});",
"});"
],
"description": "Jest short test"
}
}