Skip to content

Instantly share code, notes, and snippets.

@mbchoa
Created January 14, 2024 05:46
Show Gist options
  • Save mbchoa/d3865c6989a55424900a3d2c65c7abab to your computer and use it in GitHub Desktop.
Save mbchoa/d3865c6989a55424900a3d2c65c7abab to your computer and use it in GitHub Desktop.
function composeProviders(providers) {
return providers.reduce((AccumulatedProviders, [Provider, props = {}]) => {
return ({ children }) => (
<AccumulatedProviders>
<Provider {...props}>{children}</Provider>
</AccumulatedProviders>
);
}, ({ children }) => <>{children}</>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment