Like the callback hell, usual when jQuery was used for everything, the React Context hell is the nasty code you get taking advantage of the React Context API.
constApp=()=>{// ... some codereturn (<><ReduxProvidervalue={store}><ThemeProvidervalue={theme}><OtherProvidervalue={otherValue}><OtherOtherProvidervalue={otherOtherValue}>{/** ... other providers*/}<HellProvidervalue={hell}><HelloWorld/></HellProvider>{/** ... other providers*/}</OtherOtherProvider></OtherProvider></ThemeProvider></ReduxProvider></>)}
How to fix it?
To clean up the nasty code you get from taking advantage of React Context API we need a way to nest multiple Context.Provider without passing them as children of each other.
Clone and return a new React element using element as the starting point. The resulting element will have the original element’s props with the new props merged in shallowly. New children will replace existing children. key and ref from the original element will be preserved.
We can use the cloneElement API to reduce a collection of providers, this way we don't have to nest them inside each other.