I'm building a React Native application (using Redux(Thunk)) where I lately have been facing performance issues that I haven't been able to find a good solution to.
The issue is that the UI/App is freezing/blocked every time I call an action, whether the state changes or not. The app is dealing with accounts data, and the issue started when the account count grew to about 3k accounts. I tested the following:
- The time it takes to create the new state in the reducer.
- For unnecessary renders.
- Any manipulation on the data done in mapStateToProps or elsewhere.
None of the above is taking long or seems to be the issue. The example that I am testing on is a list view of the accounts, with an animated pop up for filtering. When I add a filter in the pop up and saves it (updates the store and closes pop up), I can see the accounts filtering instantly behind the pop up, but the UI/pop up animations is frozen for 2-3 seconds, before closing.
The data is stored with id's as index for accounts and a separate object for filters:
{
accountByIds: { acc1: {...}, acc2: {...} },
filters: {...}
}
I have been wondering whether using ImmutableJS would help, but as the application have grown rather large and I am not sure this would help, as the issue doesn't seem to be to many renders etc., I haven't changed it.
I am currently updating the store like below:
return {
...state,
filters: {
...state.filters,
newFilter
}
}
In sum up, it seems that when the store updates, the appropriate renders are called right away, but then the app seems to freeze up for a moment.
If anyone is able to shed any light on this or point me in the right direction I would appreciate it.