Skip to content

Commit e5992a6

Browse files
committed
feat: update react component with prop-type snippets
1 parent 1618bd5 commit e5992a6

File tree

3 files changed

+15
-121
lines changed

3 files changed

+15
-121
lines changed

snippets/javascript.json

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -231,34 +231,17 @@
231231
"scope": "javascript,javascriptreact"
232232
},
233233
"🟨 reactFnCompPropTypes": {
234-
"prefix": "rFCp.$rFCp",
234+
"prefix": "rFCpropType.$rFCpropType",
235235
"body": [
236236
"import PropTypes from 'prop-types'",
237237
"",
238-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}() {$0",
239-
"\treturn (",
240-
"\t\t<${2:div}>${3:$1}</$2>",
241-
"\t)",
242-
"}",
243-
"",
244-
"$1.propTypes = {}",
245-
""
246-
],
247-
"description": "React Functional Component with PropTypes",
248-
"scope": "javascript,javascriptreact"
249-
},
250-
"🟨 reactFnCompPropTypesChldrn": {
251-
"prefix": "rFCpch.$rFCpch",
252-
"body": [
253-
"import PropTypes from 'prop-types'",
254-
"",
255-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ children }) {$0",
238+
"export ${1:default }function ${2:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ children }) {$0",
256239
"\treturn (",
257-
"\t\t<${2:div}>${3:{ children \\}}</$2>",
240+
"\t\t<${3:div}>${4:{ children \\}}</$3>",
258241
"\t)",
259242
"}",
260243
"",
261-
"$1.propTypes = {",
244+
"$2.propTypes = {",
262245
"\tchildren: PropTypes.node.isRequired",
263246
"}",
264247
""
@@ -308,26 +291,7 @@
308291
"scope": "javascript,javascriptreact"
309292
},
310293
"🟨 reactArrowFnCompPropTypes": {
311-
"prefix": "rAFCp.$rAFCp",
312-
"body": [
313-
"import PropTypes from 'prop-types'",
314-
"",
315-
"const ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}} = () => {$0",
316-
"\treturn (",
317-
"\t\t<${2:div}>${3:$1}</$2>",
318-
"\t)",
319-
"}",
320-
"",
321-
"$1.propTypes = {}",
322-
"",
323-
"export default $1",
324-
""
325-
],
326-
"description": "React Arrow Function Component with PropTypes",
327-
"scope": "javascript,javascriptreact"
328-
},
329-
"🟨 reactArrowFnCompPropTypesChldrn": {
330-
"prefix": "rAFCpch.$rAFCpch",
294+
"prefix": "rAFCpropType.$rAFCpropType",
331295
"body": [
332296
"import PropTypes from 'prop-types'",
333297
"",

snippets/typescript.json

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -231,34 +231,17 @@
231231
"scope": "javascript,typescript,javascriptreact,typescriptreact"
232232
},
233233
"🟨 reactFnCompPropTypes": {
234-
"prefix": "rFCp.$rFCp",
234+
"prefix": "rFCpropType.$rFCpropType",
235235
"body": [
236236
"import PropTypes from 'prop-types'",
237237
"",
238-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}() {$0",
239-
"\treturn (",
240-
"\t\t<${2:div}>${3:$1}</$2>",
241-
"\t)",
242-
"}",
243-
"",
244-
"$1.propTypes = {}",
245-
""
246-
],
247-
"description": "React Functional Component with PropTypes",
248-
"scope": "javascript,typescript,javascriptreact,typescriptreact"
249-
},
250-
"🟨 reactFnCompPropTypesChldrn": {
251-
"prefix": "rFCpch.$rFCpch",
252-
"body": [
253-
"import PropTypes from 'prop-types'",
254-
"",
255-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ children }) {$0",
238+
"export ${1:default }function ${2:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ children }) {$0",
256239
"\treturn (",
257-
"\t\t<${2:div}>${3:{ children \\}}</$2>",
240+
"\t\t<${3:div}>${4:{ children \\}}</$3>",
258241
"\t)",
259242
"}",
260243
"",
261-
"$1.propTypes = {",
244+
"$2.propTypes = {",
262245
"\tchildren: PropTypes.node.isRequired",
263246
"}",
264247
""
@@ -308,26 +291,7 @@
308291
"scope": "javascript,typescript,javascriptreact,typescriptreact"
309292
},
310293
"🟨 reactArrowFnCompPropTypes": {
311-
"prefix": "rAFCp.$rAFCp",
312-
"body": [
313-
"import PropTypes from 'prop-types'",
314-
"",
315-
"const ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}} = () => {$0",
316-
"\treturn (",
317-
"\t\t<${2:div}>${3:$1}</$2>",
318-
"\t)",
319-
"}",
320-
"",
321-
"$1.propTypes = {}",
322-
"",
323-
"export default $1",
324-
""
325-
],
326-
"description": "React Arrow Function Component with PropTypes",
327-
"scope": "javascript,typescript,javascriptreact,typescriptreact"
328-
},
329-
"🟨 reactArrowFnCompPropTypesChldrn": {
330-
"prefix": "rAFCpch.$rAFCpch",
294+
"prefix": "rAFCpropType.$rAFCpropType",
331295
"body": [
332296
"import PropTypes from 'prop-types'",
333297
"",

src/snippets/react.ts

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,17 @@ export const reactFnCompNoExport: Snippet = {
4040
};
4141

4242
export const reactFnCompPropTypes: Snippet = {
43-
prefix: 'rFCp',
43+
prefix: 'rFCpropType',
4444
body: [
4545
"import PropTypes from 'prop-types'",
4646
'',
47-
`export default function \${1:${FILENAME_PASCALCASE}}() {$0`,
47+
`export \${1:default }function \${2:${FILENAME_PASCALCASE}}({ children }) {$0`,
4848
'\treturn (',
49-
'\t\t<${2:div}>${3:$1}</$2>',
49+
'\t\t<${3:div}>${4:{ children \\}}</$3>',
5050
'\t)',
5151
'}',
5252
'',
53-
'$1.propTypes = {}',
54-
],
55-
description: 'React Functional Component with PropTypes',
56-
};
57-
58-
export const reactFnCompPropTypesChldrn: Snippet = {
59-
prefix: 'rFCpch',
60-
body: [
61-
"import PropTypes from 'prop-types'",
62-
'',
63-
`export default function \${1:${FILENAME_PASCALCASE}}({ children }) {$0`,
64-
'\treturn (',
65-
'\t\t<${2:div}>${3:{ children \\}}</$2>',
66-
'\t)',
67-
'}',
68-
'',
69-
'$1.propTypes = {',
53+
'$2.propTypes = {',
7054
'\tchildren: PropTypes.node.isRequired',
7155
'}',
7256
],
@@ -112,25 +96,7 @@ export const reactArrowFnCompNoExport: Snippet = {
11296
};
11397

11498
export const reactArrowFnCompPropTypes: Snippet = {
115-
prefix: 'rAFCp',
116-
body: [
117-
"import PropTypes from 'prop-types'",
118-
'',
119-
`const \${1:${FILENAME_PASCALCASE}} = () => {$0`,
120-
'\treturn (',
121-
'\t\t<${2:div}>${3:$1}</$2>',
122-
'\t)',
123-
'}',
124-
'',
125-
'$1.propTypes = {}',
126-
'',
127-
'export default $1',
128-
],
129-
description: 'React Arrow Function Component with PropTypes',
130-
};
131-
132-
export const reactArrowFnCompPropTypesChldrn: Snippet = {
133-
prefix: 'rAFCpch',
99+
prefix: 'rAFCpropType',
134100
body: [
135101
"import PropTypes from 'prop-types'",
136102
'',

0 commit comments

Comments
 (0)