addReducer helper causes components to re-render unnecessarily
See original GitHub issueHi,
Thank you for this great library, it really shorten the code.
I have noticed that my components using this.global
render whenever global
is updated, even if it updates something not used by this component. Is it normal ?
I was expecting a behavior like React.PureComponent
, the component just renders when the part of the state he uses get rendered, is it possible ?
Especially in my case, I have a component that uses a reducer function, it doesn’t use a value of the state.
I am not on react 16.7 so I cannot use useGlobal
.
PS: I am on react 16.6.
Thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Optimizing React performance by preventing unnecessary re ...
This article explains how to update components only when necessary, and how to avoid common causes of unintentional re-renders. Use React.memo ...
Read more >How to debug unnecessary rerenders in React | Bryce's Blog
Common reasons for rerendering: Hooks changing (ie useState 's setState methode being called) props changing (it will list the exact props!)
Read more >Do Redux selectors cause unnecessary component renders?
Whether the component will re-render depends on what mapStateToProps returns. (Actually, it depends on the combined props object returned by ...
Read more >Just Say No to Excessive Re-Rendering in React - GrapeCity
It is possible to accidentally create new props objects and force components to re-render unnecessarily. As we continue to delve deeper into ...
Read more >5 Ways to Avoid React Component Re-Renderings
Memoization enables your code to re-render components only if there's a change in the props. With this technique, developers can avoid unnecessary ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for reporting this. I’ve pinpointed the bug, and I’ll deploy 0.1.1 sometime today to resolve it.
Thanks for providing an example.
What version of ReactN are you using? 0.0.9 or 0.1.0?EDIT: This does look to be a bug with the
addReducer
helper.You can see that it does not occur with the
setGlobal
method:I’ll look into getting this fixed for the addReducer helper as well.