Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which library is better for offline support: redux-offline or react-native-offline?

Need suggestion on which library to use for a large react native mobile app using redux ? redux-offline or react-native-offline ?

I need to regularly check connection status, render view depending on the connection status, add actions to queue when offline and run them when online, cancel actions if some contradiction is there, and persist/rehydrate data offline.

like image 305
usafder Avatar asked Apr 18 '18 21:04

usafder


People also ask

Does React Native support offline?

The most popular methods to achieve offline support in React Native are by implementing usage restrictions, caching, and request queuing.

Can redux work offline?

We can fire actions and recalculate analytics in mobile app even in offline mode, because obviously internet connection is not a requirement for Redux to work.

Should I use redux with React Native?

Advantages of Using Redux In React NativeIt is simple to understand code problems, network errors, and other types of bugs that may arise during production by logging actions and states. Server-side rendering: Redux can also be used to render data on the server.

How do I store data offline in react?

The Async Storage is a simple key-value pair based storage system in React Native. It is used for scenarios where you want to save the user's data on the device itself instead of using any cloud service, such as building offline apps.


2 Answers

I am using redux-offline in my react-native project, it works just great. The feature that you are looking for all are presents like

  1. It regularly checks for connection status
  2. Add action to offline anytime (online \ offline)
  3. Run the action as soon as device became online (moreover, you can decide the retry interval)
  4. You can write your own discard method to drop any action based on your business requirement.
  5. It uses redux-persist which automatically persist\rehydrate data. Also, you can provide your own store mechanism.

redux-offline is working just great for me, Sorry, I haven't used react-native-offline yet so can't provide you any benchmark.

like image 53
Prasun Avatar answered Sep 27 '22 18:09

Prasun


I would suggest going for react-native-offline.

React-native-Offline provides :

  1. Easier queue handling for actions based on a regex expression or a list of actions
  2. Auto Triggering the online only actions , once the network is back.
  3. Your Saga looks cleaner and readable, with both online/offline cases , on a maintenance perspective.

Redux-Offline provides:

  1. It basically on separate online and offline actions
  2. Each action and associated rollback needs to be handled

Both provides the redux-presist with connectors of your preference.

like image 24
AmalMenachery Avatar answered Sep 27 '22 20:09

AmalMenachery