Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is considered "Too much data" in react state

I'm currently building an app with a dashboard that lists a ton of statistics. The data is loaded via an API and stored in my component's state (currently not using redux — just plain react). I'm loading more than 100.000 (small) rows of data, and storing them as an array in state. My question is: at what point does the size of my state become a problem? Surely there will be memory limitations at some point? is 100.000 entries in an array a problem, is 1.000.000? And if yes, what are alternative solutions to handling this amount of data? Is this where redux can help?

like image 304
Malibur Avatar asked Mar 26 '19 09:03

Malibur


1 Answers

For the most part, it does not matter Where you store this data as much as how much of data you are storing. All of the data that you store, regardless of whether in a store or in a static variable, is stored in RAM. Because of this, your application might crash the browser because of taking too much resources.

A much better solution for storage (If you absolutely have to store data client-side) is to use something called IndexedDB. IndexedDB stores data in your hard disk instead of RAM

In most use-cases however, it is recommended to store the data in the backend, paginate it, and then send only the individual pages to the client as needed. This ensures that

  • The client doesn't have to load a massive chunk of data before the application works.

  • The client does not have to store large amounts of data in RAM.

like image 199
ManavM Avatar answered Sep 30 '22 03:09

ManavM