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.
π I enjoy programming in JavaScript. My industry experience is in Angular and Ionic Framework. I teach fundamentals of JavaScript and front-end frameworks in Oslo.
P.S. I love hamburgers. π
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.
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.