DEV Community

Discussion on: React: ContextAPI as a State solution?

dikamilo profile image

As you're mentioned, any component that uses useAppState will be re-rendered when state changes, and this is because you're grouped all state object into single Context. This may be a big drawback in application, so you're may consider splitting state into multiple Contexts.

Sometimes separate state solution is too big gun for the problem, when you're having a little state to manage in application and Context API may resolve this problem.

And if you keep data from the backend in your global store, you may consider to use for example react-query that will cache your data without global store.

dewaldels profile image
Dewald Els Author

Yeah, that is one major drawback for this approach! I’ve only used Redux as a state management solution. I’ll certainly look into react-query.