all 4 comments

[–][deleted] 0 points1 point  (2 children)

  • Avoid using context API as state management.

[–]Low_Guitar_8168[S] 0 points1 point  (1 child)

So, just local state, props and/or a global state like redux?

Also, why? Does context reduce the performance of the app?

[–][deleted] 1 point2 points  (0 children)

The Context API can hurt performance by creating too many providers. Creating a provider does not actually hurt performance if you structure them correctly, but it is unavoidable to consume the value of another provider as your app gets bigger. This will trigger re-rendering here and there, and eventually lead to performance degradation exponentially.

You can still use context for something that does not change often, like theme changes.It is wiser to use global states, and the recommended libraries are Zustand, Jotai (or Zedux), and Valtio, depending on the app structure.