thewei / react-native-store

A simple database base on react-native AsyncStorage.
https://github.com/thewei/react-native-store
Other
569 stars 74 forks source link

overwriting the last item #52

Open flamingo-peacock opened 7 years ago

flamingo-peacock commented 7 years ago

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?

wjyx1lalala commented 7 years ago

i have get the same problems!!!

lucasrocha7111 commented 7 years ago

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.