0

Is any performance issue with put many items in redux-store? for example, the store is like this:

{
    user:{...},
    userDetail:{},
    shoppingCart:{},
    OrderDetail:{},
    ...
}

Its keys count is almost 50 items.

I'm using react-redux in my project to store any data (even data that are used in one section of my app and are not share).

Ahmad Khani
  • 850
  • 2
  • 10
  • 15
  • 1
    Performance-wise, it really depends by how much each element grows in size. I would rather create several stores to keep the code clean. E.g. a store for the cart, a store for the user and so on. – Michele Jul 01 '19 at 09:52

1 Answers1

1

It's all about the size of your data, and the way you use it.

data size

You've said you have around 50 items. does each item is an object? does it have 20 properties? maybe 20,000 properties? I've used redux with around 10,000 complex items (20-30 properties each) and did not experience issues, but your data / behavior might be very different

data usage

How do you treat each change? Is the effect cause a minor change, or do you change the DOM significantly? do you use redux selectors?

Remember that when it comes to performance, Rendering is usually much more costly than updating a data object (even a large one like redux store), so for more cases it's not your state management, it's how you use it.

However, that does not mean you may not encounter problems, so the best way to approach it would be to actually test the problematic scenarios, probably with a benchmark test.

Generally speaking, redux considerated to be a highly-performant state-management system, considering you use it properly:

Use selectors when required, write proper reducers and splitting ui & data effectively to reducers etc.

yuval.bl
  • 4,890
  • 3
  • 17
  • 31
  • So you mean there is not any difference in **performance** between using state or global store? – Ahmad Khani Jul 01 '19 at 11:53
  • What do you mean by `global store`? – yuval.bl Jul 03 '19 at 08:16
  • I say that it's probably not about redux, which have great performance, it's about how you use it, and what cause elements to render – yuval.bl Jul 03 '19 at 08:18
  • when I say `global store` i mean `redux store`; – Ahmad Khani Jul 03 '19 at 09:43
  • my concern is that when importing redux and saga in my project and use it to manage store it cause performance issue because it is not like state; – Ahmad Khani Jul 03 '19 at 09:51
  • I think the `state` is faster than `redux-store`, isn't it? – Ahmad Khani Jul 03 '19 at 09:52
  • You're comment suggets that you might have a confusion about these terms. A *store* in redux, is a structure which hold your basic redux functions, like *getState* and *dispatch*. A *state* is an object which represent your application at a specific point in time. So, in redux, a state is part of your store. or more accurately, a store is a container for your state (among other things) – yuval.bl Jul 03 '19 at 13:05
  • Maybe this will clarify some things for you https://stackoverflow.com/questions/56747624/what-does-a-state-mean-in-angular-application/56749118#56749118 – yuval.bl Jul 03 '19 at 13:06