Alternatives to AsyncStorage

Viewed 1291

I have an application that is based on cards (swiping left and right)

When I swipe left or right I have functions assigned to it.

SwipeRight: (Functions performed when shifting to the right)

storeInLevel1(props.id)
removeFromLevel0(props.id)

const filterDataList = _.filter(data, item => item.id !== props.id);
setData(filterDataList)

storeInLevel1 -> gets status from AsyncStorage for Level1 and saves additional information to AsyncStorage

removeFromLevel0 -> gets status from AsyncStorage for Level0 and saves additional information to AsyncStorage (without element removed)

The problem is that it is asynchronous and does not always work properly. Asynchronity causes a lot of problems.

Sometimes it will write and read everything well (on time) and sometimes it won't work at all

Are there any better alternatives to saving simple data in the phone's memory for applications?

Maybe some text files? There must be a quick read and write of this data

2 Answers

you can use react-redux for state management, giving you a secondary layer where your states will not lose data, or you can use use-global-hook which is lightweight and does the same work to some extent.

If you want to save data in memory just use setState or context.

Related