Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nairgh/useoptimistichook
useOptimisticHook
https://github.com/nairgh/useoptimistichook
react19 useoptimistichook vite
Last synced: about 1 month ago
JSON representation
useOptimisticHook
- Host: GitHub
- URL: https://github.com/nairgh/useoptimistichook
- Owner: nairgh
- Created: 2024-08-18T02:31:20.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-18T02:32:07.000Z (5 months ago)
- Last Synced: 2024-08-18T03:31:13.300Z (5 months ago)
- Topics: react19, useoptimistichook, vite
- Language: JavaScript
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React 19 useOptimistic Hook
useOptimistic is a React Hook that lets you show a different state while an async action is underway.
It accepts some state as an argument and returns a copy of that state that can be different during
the duration of an async action such as a network request. You provide a function that takes the
current state and the input to the action, and returns the optimistic state to be used while the action
is pending.This state is called the “optimistic” state because it is usually used to immediately present
the user with the result of performing an action, even though the action actually takes time to complete.![uastate](https://github.com/user-attachments/assets/a7f9caa0-7a50-4c55-8254-8793953b5239)