polemius/recoil-persist

MergeItem for ReactNative?

hayyaun opened this issue ยท 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 Thank you for rising the issue! Could you please provide some code?

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.

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

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