Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should large amounts of data go in the app state in redux?

Tags:

reactjs

redux

Let's say I have some data tables, like a list an admin report returning a list of users (with details) or a list of log records. Does this info belong in the redux store, where only the data table needs this info? Or what if I am plotting something with 5000 nodes. Does this belong in redux single app state too? Why or why not?

If these items do not belong in the app state, is it just the local component state I should be loading these into without redux? Seems nice to have all my async requests fetched similarly, though.

like image 950
Bradford Avatar asked Oct 20 '15 17:10

Bradford


People also ask

How much data can I store in my Redux state?

Your Redux store imposes no limitations on the size of the data stored. Dispatching an action that performs this operation will not downgrade the performance of your app, so you can safely store any amount of data in your app's state.

What are the best practices for using Redux on large applications?

The following points of discussion should help anyone working with Redux on large, data intensive applications: Section 2: Separation of state between data objects, edits to those objects, and other UI state Section 3: Sharing of state between multiple screens in a Single Page Application, and when not to

What is a redux store?

Redux stores are global states that store data you want to use across multiple components without drilling props at every level in your component tree. As an app gets large and complex, you might want to store large, bulky data inside your Redux store and access it inside a component.

What happens when I add large data to the App State?

This adds the large data inside the store without any flickering or UI lag, indicating that there is no performance difference when you add large data in the app state. You can try out with an even larger data set but the results will be the same.


1 Answers

Since redux doesn't care about the data (it literally just calls reducer functions when actions are dispatched, and replaces the current state with the result), there shouldn't be any performance issue there. It will be as performant as the reducer functions you provide.

If you'd like to see for this directly: https://github.com/rackt/redux/blob/master/src/createStore.js#L115

You're more likely to run into performance issues with react, but even then its doubtful at that scale. You may want to virtualize your table so that you're not rendering out of view elements, but that's a common problem with ui programming.

like image 73
Nathan Hagen Avatar answered Sep 20 '22 15:09

Nathan Hagen