简体   繁体   中英

Store object size on react-redux

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM