-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Provide clearNuxtState function for useState #21293
Copy link
Copy link
Closed
Description
Describe the feature
The useState uses useNuxtApp().payload.state to preserve the value after server-side rendering and share the value across all components through a unique key. If useState is previously used with a key and if the key is the same, it will use the cached value regardless of whether it has a different init method or not. It is useful to use cached data when needed. However, in some cases, the value of useState needs to be redeclared with a new init method. It seems like the only way is creating unique key every time.
It would be nice to have just like clearNuxtData function to clear cached state value, so we don't have to think how to make a unique key when we want to change the value of useState
Additional information
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Read the contribution guide.
- Check existing discussions and issues.
Reactions are currently unavailable