DEV Community

Discussion on: Global state management in React with global variables and hooks. State management doesn't have to be so hard.

Collapse
 
yezyilomo profile image
Yezy Ilomo

Thanks for the feedback, I haven't showed its purpose in this post so you can safely ignore it but the intention was to pass it in case you want to avoid re-rendering if the global value hasn't changed, which in that case you would compare the old value and the new value and decide weather to rerender or not, so in short its purpose is to avoid unnecessary rerenders which is something I haven't showed in this post. You can check how I've used it in my library I mentioned to accomplish that.