Recoil icon indicating copy to clipboard operation
Recoil copied to clipboard

How to clear all atomic states and restore them to default values

Open SGDS666 opened this issue 1 year ago • 1 comments

I have a requirement now Users have multiple accounts The requested data for each account is globally stored using recoil To enable components to be freely and infinitely split without worrying about data transmission But when the user switches accounts These data caches seem to have lost value. I hope to clear all the data caches when switching accounts and welcome new account data At present, it seems that there is only a solution for refreshing the page, and the experience is not very good Perhaps all I can do myself is manually integrate all recoil data and batch clear it

Here is my solution for combining recoil to cache network data https://github.com/SGDS666/single_request

SGDS666 avatar Jul 20 '23 16:07 SGDS666

I believe you can reset the data by referring to this document: https://recoiljs.org/docs/guides/dev-tools/#time-travel. You just need to go back to the earliest snapshot when switching accounts.

liamfend avatar Aug 07 '23 16:08 liamfend