yarn add @saneksa/react-context-composer
In projects on react there are a lot of contexts, it becomes very difficult to read such things
<ContextA.Provider>
<ContextB.Provider>
<ContextC.Provider>...</ContextC.Provider>
</ContextB.Provider>
</ContextA.Provider>
See it in action at codesandbox
function App() {
return composeContexts([
[ThemeContext, theme[Theme.red]],
[LanguageContext, Languages.cn],
])(
<div>
<Children />
<br />
...child elements using contexts
</div>
);
}
In my proposed variant, the check of context value types works correctly