-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtsx.code-snippets
executable file
·69 lines (69 loc) · 2.56 KB
/
tsx.code-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
{
// React (TS)
"component static prop types": {
"prefix": "propTypes",
"body": "static propTypes = {$0}",
"description": "Component Static Prop Types"
},
"component static default props": {
"prefix": "defaultProps",
"body": "static defaultProps: Partial<${1:${TM_FILENAME_BASE}Props}> = {$0}"
},
"component static get derived state from props": {
"prefix": "getDerivedStateFromProps",
"body": "static getDerivedStateFromProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:prevState}: ${6:${TM_FILENAME_BASE}${5:State}}): Partial<${6:${TM_FILENAME_BASE}${5:State}}> {$0}"
},
"component set state": {
"prefix": "setState",
"body": "this.setState($1)$0"
},
"component constructor": {
"prefix": "constructor",
"body": [
"constructor(${1:props}: ${3:${TM_FILENAME_BASE}${2:Props}}) {",
"\tsuper(${1:props})",
"",
"\t$4",
"}"
]
},
"component will mount": {
"prefix": "componentWillMount",
"body": "componentWillMount() {$0}",
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidMount` instead."
},
"component did mount": {
"prefix": "componentDidMount",
"body": "componentDidMount() {$0}"
},
"component will receive props": {
"prefix": "componentWillReceiveProps",
"body": "componentWillReceiveProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}) {$0}",
"description": "DEPRECATION WARNING [v16.3]: Use `static getDerivedStateFromProps` instead."
},
"should component update": {
"prefix": "shouldComponentUpdate",
"body": "shouldComponentUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {$0}"
},
"component will update": {
"prefix": "componentWillUpdate",
"body": "componentWillUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {$0}",
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidUpdate` instead."
},
"component did update": {
"prefix": "componentDidUpdate",
"body": "componentDidUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {$0}"
},
"component will unmount": {
"prefix": "componentWillUnmount",
"body": "componentWillUnmount() {$0}"
},
"component did catch": {
"prefix": "componentDidCatch",
"body": "componentDidCatch(${1:error}: Error, ${2:errorInfo}: React.ErrorInfo) {$0}"
},
"component render": {
"prefix": "render",
"body": ["render() {", "\treturn ($0)", "}"]
}
}