Difference between storing data in React-Navigation params and Redux State directly

299 views Asked by At

Let's say I have a collection, consisting of 3 objects in my Tab-Navigator of React-Navigation, which is integrated into Redux. Each of these 3 screens of TN displays the data list of its own unique object. I use Redux to:

  1. fetchCollection from the online database on app start
  2. loadUpdatedObject from the online database if I made changes to any of its properties (add, edit, delete)
  3. filterDisplayedList by search predicate when the search is performed
  4. addItem, editItem, deleteItem (3 different action creators)

What would be the difference between storing the whole collection and filtered objects in:
1. In navigation.state.params by assigning through:
navigation.SetParams(object)
2. In Redux Store directly by dispatching them from Action Creator(s) using: navigation.dispatch(type, payload)

1

There are 1 answers

1
Victor On BEST ANSWER

Using Redux Store , we can access it anywhere from the app. You just need to connect the store with the containers.

Using navigation setParams, u have do it for every screen i think.

Better approach will be the redux as the business logic and everything will be separate and code will be cleaner and easy to maintain.