Provider Composer

Last update in 2/2019

If you hate having 10 nested providers on your root component, you should try this out. Simply wrap root component with ProviderComposer and pass all providers in array as props.

const ProviderComposer = ({ contexts, children }) => {
return contexts.reduceRight(
(kids, parent) =>
React.cloneElement(parent, {
children: kids,
}),
children
)
}