See it in action at https://codesandbox.io/s/n6txl.
Have you ever come across a tree like this:
<ContextA.Provider>
<ContextB.Provider>
<ContextC.Provider>
...
</ContextC.Provider>
</ContextB.Provider>
</ContextA.Provider>
Instead, we can compose/combine this list of providers:
<Compose items={[
[ContextA, props],
[ContextB, props],
[ContextC, props],
]}>
...
</Compose>
Hey! Here is a TS version. Could be helpful for someone: