You Might Not Need an Effect
See https://react.dev/learn/you-might-not-need-an-effect
useEffect can lead to clunky code, as well as performance issues.
What other alternatives do we have?
- Quite often, we will be able to achieve the same functionality by adding the logic straight in the jsx or by setting up an extra function in the Component.
- For data fetching, replace useEffect with libraries
- These libraries also take care of things like caching and synchronization
- react-query
- rtk query
- swr or next.js