recoil-persist icon indicating copy to clipboard operation
recoil-persist copied to clipboard

MergeItem for ReactNative?

Open hayyaun opened this issue 3 years ago • 4 comments

Hi, I faced an issue for persisting multiple atoms when I set them right after each other, how can I fix this problem?

hayyaun avatar Mar 02 '21 10:03 hayyaun

@hayyaun Thank you for rising the issue! Could you please provide some code?

polemius avatar Mar 03 '21 11:03 polemius

Hi, I tried another solution, by separating each state at a unique key in storage. This was the only solution I found for react native up to now. I'm waiting for your next version to come.

My code was something like this:

setUser({ ... });
setProducts({ ... });

In this case, since they were trying to be stored syncly, and the current state retrieved from storage is not updated would end up one state not to be saved properly.

hayyaun avatar Mar 03 '21 12:03 hayyaun

I ran into something similar, setting multiple atoms that shared the same persistAtom then the save of the last one would overwrite the save of the first one. My current fix is to give all of them different persistAtoms

dpalay avatar Mar 05 '21 17:03 dpalay

@hayyaun I have released 2.9.0 version with using mergeItem function. Please check it out

polemius avatar May 25 '21 20:05 polemius