Skip to content

Commit 250ef09

Browse files
committed
Add useOptimistic hook snippet and update README
1 parent 2ac4c1a commit 250ef09

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
React Hooks Snippets is a [Visual Studio Code](https://code.visualstudio.com/) extension to make writing [React Hooks](https://react.dev/reference/react/hooks) easier and faster!
88

9-
109
## Supported Hooks
1110

1211
### State Hooks
@@ -48,6 +47,7 @@ React Hooks Snippets is a [Visual Studio Code](https://code.visualstudio.com/) e
4847
| `uidh` | `useId` |
4948
| `usesh` | `useSyncExternalStore` |
5049
| `uash` | `useActionState` |
50+
| `uoh` | `useOptimistic` |
5151

5252
## Add to your project
5353

snippets/snippets.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,12 @@
128128
"const [${1:state}, ${2:formAction}, ${3:isPending}] = useActionState(${4:fn}, ${5:initialState});$0"
129129
],
130130
"description": "React useActionState() hook"
131+
},
132+
"useOptimistic": {
133+
"prefix": "uoh",
134+
"body": [
135+
"const [${1:optimisticState}, ${2:addOptimistic}] = useOptimistic(${3:state}, ${4:updateFn});$0"
136+
],
137+
"description": "React useOptimistic() hook"
131138
}
132139
}

0 commit comments

Comments
 (0)