Alternatives to contexts
We should be careful not to use React Context too often, as it makes reusing components more difficult. We should only use context when we need to access data in many components, which are at different nesting levels. Additionally, we need to make sure that we only use contexts for non-frequently changing data. Frequently changing values of contexts, especially contexts that are used high up in the component tree, may cause large parts of the component tree to re-render, resulting in performance problems. That is why, for frequently changing values, we should use a state management solution such as Jotai, Redux, or MobX instead. These state management solutions allow us to access small parts of the state in a fine-grained way and thus reduce the amount of re-renders. Good candidates for contexts are features such as theming and translation (i18n) systems.
If we only want to avoid having to pass down props, in some cases, we can pass down the rendered component...