Skip to content

Commit ab86485

Browse files
AmelloAsterxhe
andauthored
feat: add usecallback snip (#66)
* feat: add usecallback sinp * docs: update readme Co-authored-by: xhe <[email protected]>
1 parent b199e60 commit ab86485

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

packages/vscode/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@
6363
const value = useContext(myContext);
6464
```
6565

66-
9. `rur` (useRef hook)
66+
9. `rucb` (useCallback hook)
6767

6868
```jsx
69-
const refContainer = useRef(initialValue);
69+
const handleCallback = useCallback(() => {}, []);
7070
```
7171

72+
10. `rur` (useRef hook)
73+
74+
```jsx
75+
const refContainer = useRef(initialValue);
76+
```
77+
7278
### TypeScript
7379

7480
1. `rfcet` (React functional component)
@@ -103,7 +109,13 @@
103109
const value = useContext(myContext);
104110
```
105111

106-
5. `rurt` (useRef hook)
112+
5. `rucbt` (useCallback hook)
113+
114+
```jsx
115+
const handleCallback = useCallback(() => {}, []);
116+
```
117+
118+
6. `rurt` (useRef hook)
107119

108120
```tsx
109121
const refContainer = useRef(initialValue);

packages/vscode/snippets/react-javascript.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444
"body": ["const ${1} = useContext(${2});"],
4545
"description": "JavaScript: useContext hook"
4646
},
47+
"rucb": {
48+
"prefix": "rucb",
49+
"body": [
50+
"const handleCallback = useCallback(() => {",
51+
"\t$1",
52+
"}, [${2}]);"
53+
],
54+
"description": "JavaScript: useCallback hook"
55+
},
4756
"rur": {
4857
"prefix": "rur",
4958
"body": ["const ${1} = useRef(${2});"],

packages/vscode/snippets/react-typescript.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@
4747
"body": ["const ${1} = useContext(${2});"],
4848
"description": "TypeScript: useContext hook"
4949
},
50+
"rucbt": {
51+
"prefix": "rucbt",
52+
"body": [
53+
"const handleCallback = useCallback(() => {",
54+
"\t$1",
55+
"}, [${2}]);"
56+
],
57+
"description": "TypeScript: useCallback hook"
58+
},
5059
"rurt": {
5160
"prefix": "rurt",
5261
"body": ["const ${1} = useRef(${2});"],

0 commit comments

Comments
 (0)