Skip to content

Commit 88b2a00

Browse files
committed
Added new snipper for stateful components with State, Props, and constructor.
1 parent 6cf5955 commit 88b2a00

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-react-typescript",
3-
"version": "1.0.10",
3+
"version": "1.0.20",
44
"description": "Code snippets for react in typescript",
55
"displayName": "Typescript React code snippets",
66
"publisher": "infeng",

snippets/snippets.json

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,43 @@
2020
],
2121
"description": "Create a React Component with typescript."
2222
},
23+
"React Component - Full": {
24+
"prefix": "tsrcfull",
25+
"body": [
26+
"import * as React from 'react';",
27+
"",
28+
"export interface ${1:App}Props {",
29+
"}",
30+
"",
31+
"export interface ${1:App}State {",
32+
"}",
33+
"",
34+
"export default class ${1:} extends React.Component<${1:}Props, ${1:}State> {",
35+
" constructor(props: ${1:}Props) {",
36+
" super();",
37+
"",
38+
" this.state = {",
39+
" }",
40+
" }",
41+
"",
42+
" render() {",
43+
" return (",
44+
" <div>",
45+
" ${2:}",
46+
" </div>",
47+
" );",
48+
" }",
49+
"}",
50+
""
51+
],
52+
"description": "Create a stateful React Component with typescript with Props, State, and a constructor."
53+
},
2354
"React Component without import and export": {
2455
"prefix": "tsrcjc",
2556
"body": [
2657
"export interface ${1:App}Props {",
2758
"}",
28-
"",
59+
"",
2960
"class ${1:} extends React.Component<${1:}Props, any> {",
3061
" render() {",
3162
" return (",
@@ -65,7 +96,7 @@
6596
"body": [
6697
"export interface ${1:App}Props {",
6798
"}",
68-
"",
99+
"",
69100
"class ${1:} extends React.PureComponent<${1:}Props, any> {",
70101
" render() {",
71102
" return (",
@@ -86,7 +117,7 @@
86117
"",
87118
"export interface ${1:App}Props {",
88119
"}",
89-
"",
120+
"",
90121
"export function ${1:} (props: ${1:}Props) {",
91122
" return (",
92123
" <div>",
@@ -255,4 +286,4 @@
255286
],
256287
"description": "Create a import"
257288
}
258-
}
289+
}

0 commit comments

Comments
 (0)