You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe. useUndoable has a great summary of why resetting state on useStateWithHistory is useful. I set my state to the response of a network request and want to prevent the user being able to rewind history to the initial value set before the request had finished.
Describe the solution you'd like
Add a method to useStateWithHistory that follows the API of useUndoable's resetInitialState, where it takes in a param to set the state to and clears the history.
Describe alternatives you've considered
There are two alternatives I've been using:
using useUndoable instead of this library (but it doesn't work for deeply nested objects and is an additional dependency)
Manually extending the useStateWithHistory myself to include this method. The method is really easy to add:
This seems to have been requested already in #1386 but I'm re-raising here because:
I believe the interface of useUndoable is relevant, I'm providing a proposed solution, and that issue has been open for over 2 years.
If approved i'd even be happy to raise a PR myself.
Thanks!
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
useUndoable has a great summary of why resetting state on useStateWithHistory is useful. I set my state to the response of a network request and want to prevent the user being able to rewind history to the initial value set before the request had finished.
Describe the solution you'd like
Add a method to useStateWithHistory that follows the API of useUndoable's resetInitialState, where it takes in a param to set the state to and clears the history.
Describe alternatives you've considered
There are two alternatives I've been using:
This seems to have been requested already in #1386 but I'm re-raising here because:
I believe the interface of useUndoable is relevant, I'm providing a proposed solution, and that issue has been open for over 2 years.
If approved i'd even be happy to raise a PR myself.
Thanks!
The text was updated successfully, but these errors were encountered: