DEV Community

Discussion on: How to write performant React apps with Context

 
adevnadia profile image
Nadia Makarevich

Context is just a tool with its own set of benefits and downsides, like any other tool. I wouldn't make strict generalisation when it should and shouldn't be used.

And I believe that the most important thing is to understand how tools like that work, so that it's possible to make an informed decision for every situation, without just relying on generalisations like "Context shouldn't be used for state management". It can and should if there is a problem that it solves better than other tools.

In real life more likely than not there will be a state management library already for a form like that. Or it will be not that big to cause any performance concerns even with props drilling through the entire form. So the use of Context there will not be necessary.

I certainly do not claim that we should use Context for everything. Just that sometimes it can be useful and that use is not limited to global things like theming. And that there are some patterns available that can mitigate its downsides.