Skip to content

Commit

Permalink
feat: update useMemo & useCallback snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
afiiif committed Feb 21, 2023
1 parent 07ac42a commit 1d52d32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
6 changes: 2 additions & 4 deletions snippets/javascript.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@
"🟨 useMemo": {
"prefix": "useMemo.$useMemo",
"body": [
"const ${1:memo} = useMemo$4(() => ${3:computeValue}, [$2])",
""
"const ${1:memo} = useMemo$4(() => ${3:computeValue}, [$2])"
],
"description": "React useMemo",
"scope": "javascript,javascriptreact"
Expand All @@ -461,8 +460,7 @@
"body": [
"const ${1:callback} = useCallback$4(() => {",
"\t${3:// code}",
"}, [$2])",
""
"}, [$2])"
],
"description": "React useCallback",
"scope": "javascript,javascriptreact"
Expand Down
12 changes: 4 additions & 8 deletions snippets/typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,7 @@
"🟨 useMemo": {
"prefix": "useMemo.$useMemo",
"body": [
"const ${1:memo} = useMemo$4(() => ${3:computeValue}, [$2])",
""
"const ${1:memo} = useMemo$4(() => ${3:computeValue}, [$2])"
],
"description": "React useMemo",
"scope": "javascript,typescript,javascriptreact,typescriptreact"
Expand All @@ -605,8 +604,7 @@
"body": [
"const ${1:callback} = useCallback$4(() => {",
"\t${3:// code}",
"}, [$2])",
""
"}, [$2])"
],
"description": "React useCallback",
"scope": "javascript,typescript,javascriptreact,typescriptreact"
Expand Down Expand Up @@ -668,8 +666,7 @@
"🟦 TS UseMemo": {
"prefix": "useMemo.TS.$$useMemo",
"body": [
"const ${1:memo} = useMemo$5<${4:any}>(() => ${3:computeValue}, [$2])",
""
"const ${1:memo} = useMemo$5<${4:any}>(() => ${3:computeValue}, [$2])"
],
"description": "React useMemo",
"scope": "javascript,typescript,javascriptreact,typescriptreact"
Expand All @@ -679,8 +676,7 @@
"body": [
"const ${1:callback} = useCallback$5<() => ${4:void}>(() => {",
"\t${3:// code}",
"}, [$2])",
""
"}, [$2])"
],
"description": "React useCallback",
"scope": "javascript,typescript,javascriptreact,typescriptreact"
Expand Down
8 changes: 6 additions & 2 deletions src/snippets/react-hook-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ export const tsUseRef: Snippet = {

export const tsUseMemo: Snippet = {
prefix: 'useMemo',
body: ['useMemo$4<${3:any}>(() => ${2:computeValue}, [$1])'],
body: ['const ${1:memo} = useMemo$5<${4:any}>(() => ${3:computeValue}, [$2])'],
description: 'React useMemo',
};

export const tsUseCallback: Snippet = {
prefix: 'useCallback',
body: ['useCallback$4<() => ${3:void}>(() => {', '\t${2:// code}', '}, [$1])', ''],
body: [
'const ${1:callback} = useCallback$5<() => ${4:void}>(() => {',
'\t${3:// code}',
'}, [$2])',
],
description: 'React useCallback',
};
4 changes: 2 additions & 2 deletions src/snippets/react-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ export const useLayoutEffectV2: Snippet = {

export const useMemo: Snippet = {
prefix: 'useMemo',
body: ['useMemo$3(() => ${2:computeValue}, [$1])'],
body: ['const ${1:memo} = useMemo$4(() => ${3:computeValue}, [$2])'],
description: 'React useMemo',
};

export const useCallback: Snippet = {
prefix: 'useCallback',
body: ['useCallback$3(() => {', '\t${2:// code}', '}, [$1])', ''],
body: ['const ${1:callback} = useCallback$4(() => {', '\t${3:// code}', '}, [$2])'],
description: 'React useCallback',
};

Expand Down

0 comments on commit 1d52d32

Please sign in to comment.