Version: v4.5.0
use-undo-state
#
AboutDrop in replacement for useState hook but with undo functionality.
#
Installation#
Importing the hook#
UsageYou can pass any kind of value to hook just like React's own useState.
Setter function can also be used with callback just like React's own useState.
To preserve memory you can limit number of steps that will be preserved in undo history.
#
ArgumentsArguments | Type | Description | Default value |
---|---|---|---|
initialValue | boolean | Initial value of the state | false |
Options | Object | An options object for the hook | {maxSize: 100} |
Note: The second argument is an options object which currently accepts a maxSize which governs the maximum number of previous states to keep track of.
#
Returned array itemsReturned Array items | Type | Description |
---|---|---|
value | Any | Current value |
setValue | function | Setter function to update value |
undo | function | Undo state value |
#
Join Bhargav's discord serverYou can click on the floating discord icon at the bottom right of the screen and talk to us in our server.