react-native-store icon indicating copy to clipboard operation
react-native-store copied to clipboard

overwriting the last item

Open flamingo-peacock opened this issue 8 years ago • 2 comments

When I try to add things to my storage, it doesn't always add correctly, and many times just overwrites the last item, it doesn't give a new id, just keeps using the last one.

I was having this issue in another part of my app, where there was a race condition and the first call hadn't finished when the second one started, but that shouldn't be the case here, nor should that be an issue anyway. Storage should be able to handle items coming in rapid succession.

thoughts?

flamingo-peacock avatar Dec 02 '16 20:12 flamingo-peacock

i have get the same problems!!!

wjyx1lalala avatar Dec 14 '16 13:12 wjyx1lalala

I "solve" this problem using setTimeout.

Like this:

setTimeout(() => { Store.model('config').add(values).then((res) => { //Something }).catch(err => { console.log('Error ', err) }) }, 80)

Working here.

lucasrocha7111 avatar Nov 21 '17 03:11 lucasrocha7111