Does deletion of unused redux fields from mapStateToProps cause a significant jump in performance

33 Views Asked by At

If we use the redux HOC mapStateToProps - we de-structure certain properties from the various sub-reducers available in our React application.

Over time, 2 things happen:

  1. some properties being extracted are not being used (if the code using it gets deleted)
  2. we extract a more generic property (a big large object) instead of specific smaller values from redux.

If we fix both these problems - in a large codebase of about 150-200 classes - will there be a significant jump in performance (since now there is lesser re-rendering) ?

Thanks

2

There are 2 best solutions below

1
abdemirza On

Fixing these issues can significantly improve the overall performance of your app and reducing the number of unused field from mapStateToProps will reduce the number of data that is passed through the component hierarchy which will result in less re-renders and keep in mind that using specific property instead of passing whole objects significantly improves the performance as we were also facing the same issues in our app and made these changes. Thank you.

0
MarkSkayff On

If properties are not being used, this means:

  1. You probably still have them in state.
  2. You have them hooked with mapStateToProps

First case it's probably normal. Maybe you still want to keep them in state for some reason or future use.

Second case, if they are not needed by the components using them with mapStateToProps you better remove them, cause they might be generating re-renders. If the Component does not need it any more, one mantainance step is to remove them from mapStateToProps.