Skip to content

Commit 9fd38b4

Browse files
committed
feat: update react component snippets
1 parent b0caa9c commit 9fd38b4

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

snippets/javascript.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@
192192
"🟨 reactFnComp": {
193193
"prefix": "rFC.$rFC",
194194
"body": [
195-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}() {$0",
195+
"export ${1:default }function ${2:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}() {$0",
196196
"\treturn (",
197-
"\t\t<${2:div}>${3:$1}</$2>",
197+
"\t\t<${3:div}>${4:$2}</$3>",
198198
"\t)",
199199
"}",
200200
""

snippets/typescript.json

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@
192192
"🟨 reactFnComp": {
193193
"prefix": "rFC.$rFC",
194194
"body": [
195-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}() {$0",
195+
"export ${1:default }function ${2:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}() {$0",
196196
"\treturn (",
197-
"\t\t<${2:div}>${3:$1}</$2>",
197+
"\t\t<${3:div}>${4:$2}</$3>",
198198
"\t)",
199199
"}",
200200
""
@@ -375,12 +375,11 @@
375375
"prefix": "rFC.TS.$$rFC.(type)",
376376
"body": [
377377
"type Props = {",
378-
"\t$2: ReactNode;",
378+
"\t$3: ReactNode;",
379379
"}",
380-
"",
381-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ ${2:children} }: Props) {$0",
380+
"export ${1:default }function ${2:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ ${3:children} }: Props) {$0",
382381
"\treturn (",
383-
"\t\t<${3:div}>${4:$1}</$3>",
382+
"\t\t<${4:div}>${5:$2}</$4>",
384383
"\t)",
385384
"}",
386385
""
@@ -394,7 +393,6 @@
394393
"type Props = {",
395394
"\t$2: ReactNode;",
396395
"}",
397-
"",
398396
"function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ ${2:children} }: Props) {$0",
399397
"\treturn (",
400398
"\t\t<${3:div}>${4:$1}</$3>",
@@ -413,7 +411,6 @@
413411
"type Props = {",
414412
"\t$2: ReactNode;",
415413
"}",
416-
"",
417414
"export const ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}} = ({ ${2:children} }: Props) => {$0",
418415
"\treturn (",
419416
"\t\t<${3:div}>${4:$1}</$3>",
@@ -430,7 +427,6 @@
430427
"type Props = {",
431428
"\t$2: ReactNode;",
432429
"}",
433-
"",
434430
"const ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}} = ({ ${2:children} }: Props) => {$0",
435431
"\treturn (",
436432
"\t\t<${3:div}>${4:$1}</$3>",
@@ -447,12 +443,11 @@
447443
"prefix": "rFC.TS.$$rFC.(interface)",
448444
"body": [
449445
"interface Props {",
450-
"\t$2: ReactNode;",
446+
"\t$3: ReactNode;",
451447
"}",
452-
"",
453-
"export default function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ ${2:children} }: Props) {$0",
448+
"export ${1:default }function ${2:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ ${3:children} }: Props) {$0",
454449
"\treturn (",
455-
"\t\t<${3:div}>${4:$1}</$3>",
450+
"\t\t<${4:div}>${5:$2}</$4>",
456451
"\t)",
457452
"}",
458453
""
@@ -466,7 +461,6 @@
466461
"interface Props {",
467462
"\t$2: ReactNode;",
468463
"}",
469-
"",
470464
"function ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}}({ ${2:children} }: Props) {$0",
471465
"\treturn (",
472466
"\t\t<${3:div}>${4:$1}</$3>",
@@ -485,7 +479,6 @@
485479
"interface Props {",
486480
"\t$2: ReactNode;",
487481
"}",
488-
"",
489482
"export const ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}} = ({ ${2:children} }: Props) => {$0",
490483
"\treturn (",
491484
"\t\t<${3:div}>${4:$1}</$3>",
@@ -502,7 +495,6 @@
502495
"interface Props {",
503496
"\t$2: ReactNode;",
504497
"}",
505-
"",
506498
"const ${1:${RELATIVE_FILEPATH/(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|page|\\[))|[.\\-_\\/\\\\])|(\\w+)/${2:/capitalize}/g}} = ({ ${2:children} }: Props) => {$0",
507499
"\treturn (",
508500
"\t\t<${3:div}>${4:$1}</$3>",

src/snippets/react-ts.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ export const tsReactFnComp: Snippet = {
55
prefix: ['rFC', '(type)'],
66
body: [
77
'type Props = {',
8-
'\t$2: ReactNode;',
8+
'\t$3: ReactNode;',
99
'}',
10-
'',
11-
`export default function \${1:${FILENAME_PASCALCASE}}({ \${2:children} }: Props) {$0`,
10+
`export \${1:default }function \${2:${FILENAME_PASCALCASE}}({ \${3:children} }: Props) {$0`,
1211
'\treturn (',
13-
'\t\t<${3:div}>${4:$1}</$3>',
12+
'\t\t<${4:div}>${5:$2}</$4>',
1413
'\t)',
1514
'}',
1615
],
@@ -23,7 +22,6 @@ export const tsReactFnCompExport: Snippet = {
2322
'type Props = {',
2423
'\t$2: ReactNode;',
2524
'}',
26-
'',
2725
`function \${1:${FILENAME_PASCALCASE}}({ \${2:children} }: Props) {$0`,
2826
'\treturn (',
2927
'\t\t<${3:div}>${4:$1}</$3>',
@@ -41,7 +39,6 @@ export const tsReactArrowFnComp: Snippet = {
4139
'type Props = {',
4240
'\t$2: ReactNode;',
4341
'}',
44-
'',
4542
`export const \${1:${FILENAME_PASCALCASE}} = ({ \${2:children} }: Props) => {$0`,
4643
'\treturn (',
4744
'\t\t<${3:div}>${4:$1}</$3>',
@@ -57,7 +54,6 @@ export const tsReactArrowFnCompExport: Snippet = {
5754
'type Props = {',
5855
'\t$2: ReactNode;',
5956
'}',
60-
'',
6157
`const \${1:${FILENAME_PASCALCASE}} = ({ \${2:children} }: Props) => {$0`,
6258
'\treturn (',
6359
'\t\t<${3:div}>${4:$1}</$3>',
@@ -73,12 +69,11 @@ export const tsReactFnCompV2: Snippet = {
7369
prefix: ['rFC', '(interface)'],
7470
body: [
7571
'interface Props {',
76-
'\t$2: ReactNode;',
72+
'\t$3: ReactNode;',
7773
'}',
78-
'',
79-
`export default function \${1:${FILENAME_PASCALCASE}}({ \${2:children} }: Props) {$0`,
74+
`export \${1:default }function \${2:${FILENAME_PASCALCASE}}({ \${3:children} }: Props) {$0`,
8075
'\treturn (',
81-
'\t\t<${3:div}>${4:$1}</$3>',
76+
'\t\t<${4:div}>${5:$2}</$4>',
8277
'\t)',
8378
'}',
8479
],
@@ -91,7 +86,6 @@ export const tsReactFnCompExportV2: Snippet = {
9186
'interface Props {',
9287
'\t$2: ReactNode;',
9388
'}',
94-
'',
9589
`function \${1:${FILENAME_PASCALCASE}}({ \${2:children} }: Props) {$0`,
9690
'\treturn (',
9791
'\t\t<${3:div}>${4:$1}</$3>',
@@ -109,7 +103,6 @@ export const tsReactArrowFnCompV2: Snippet = {
109103
'interface Props {',
110104
'\t$2: ReactNode;',
111105
'}',
112-
'',
113106
`export const \${1:${FILENAME_PASCALCASE}} = ({ \${2:children} }: Props) => {$0`,
114107
'\treturn (',
115108
'\t\t<${3:div}>${4:$1}</$3>',
@@ -125,7 +118,6 @@ export const tsReactArrowFnCompExportV2: Snippet = {
125118
'interface Props {',
126119
'\t$2: ReactNode;',
127120
'}',
128-
'',
129121
`const \${1:${FILENAME_PASCALCASE}} = ({ \${2:children} }: Props) => {$0`,
130122
'\treturn (',
131123
'\t\t<${3:div}>${4:$1}</$3>',

src/snippets/react.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Snippet } from '../types';
44
export const reactFnComp: Snippet = {
55
prefix: 'rFC',
66
body: [
7-
`export default function \${1:${FILENAME_PASCALCASE}}() {$0`,
7+
`export \${1:default }function \${2:${FILENAME_PASCALCASE}}() {$0`,
88
'\treturn (',
9-
'\t\t<${2:div}>${3:$1}</$2>',
9+
'\t\t<${3:div}>${4:$2}</$3>',
1010
'\t)',
1111
'}',
1212
],

0 commit comments

Comments
 (0)