mithi / epic-react-exercises

Practical React exercises with detailed solutions.
https://epic-react-exercises.vercel.app
Apache License 2.0
159 stars 36 forks source link

🏇🏇🏇 Refactor top-level context providers for performance #123

Open mithi opened 3 years ago

mithi commented 3 years ago

There are currently three top level providers for handling the ui state:

I have to refactor this to best practices so that the app will be faster considering the following techniques:

  1. How to optimize your context value by separating state and dispatch

  2. By using useCallback and useMemo for state update functions https://github.com/kentcdodds/kentcdodds.com/blob/319db97260078ea4c263e75166f05e2cea21ccd1/content/blog/how-to-optimize-your-context-value/index.md

Be sure to measure the performance before and after with chrome dev tools and react component profilers to make sure the changes introduced actually does make things faster... not slower.