Home > Mobile >  How can I make a React native app offline?
How can I make a React native app offline?

Time:09-27

I have a react native application to answer evaluations with different fields and load images. I need to make than the user can login and answer the evaluations offline and when the device its online, use the Web Services to load the answers automatically.

Any idea where to start or how can i do it?

CodePudding user response:

You can use Realm for that, it is a mobile database and here you can manage offline data. If you're using redux then you can also implement redux-persist, but it is a library where the data is saving to redux store in the local storage.

After that, when the device is online then sync the offline data to your web server or handle it with the automatic load.

Hope this works for you.

CodePudding user response:

First, you need to check to internet connection, to make sure the device is online or offline. For this, you can use this library @react-native-community/netinfo.

Second, you need to store the question and answer on redux, so when the device is offline, you can load the question from redux. When the device is online, you can load the question from api.

Hope this works for you.

  • Related