I have inherited a codebase where the previous owner has made extensive use of React.Context. This has resulted in what might be described as "context hell"
<AppContextProvider>
<AnotherProvider>
<AgainAnotherProvider configProp={false}>
<TestProvider>
<FooProvider>
<BarProvider configHereAlso={someEnvronmentVar}>
<BazProvider>
<BatProvider>
<App />
</BatProvider>
</BazProvider>
</BarProvider>
</FooProvider>
</TestProvider>
</AgainAnotherProvider>
</AnotherProvider>
</AppContextProvider>;
This feels like an anti-pattern and is causing considerable cognitive overhead in understanding how the whole application works.
How do I fix this? Is it possible to use just one provider for everything? I previously used redux-toolkit with redux for managing state in react. Is there anything similar for contexts?