-
-
Save johinsDev/3caa81411ed9fe06dc1aa20c3ecfdd1e to your computer and use it in GitHub Desktop.
ProviderComposer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ProviderComposer({ contexts, children }) { | |
| return contexts.reduceRight( | |
| (kids, parent) => | |
| React.cloneElement(parent, { | |
| children: kids, | |
| }), | |
| children | |
| ); | |
| } | |
| function ContextProvider({ children }) { | |
| return ( | |
| <ProviderComposer | |
| contexts={[<CheckoutProvider />, <LoginProvider />, <AlertProvider />]} | |
| > | |
| {children} | |
| </ProviderComposer> | |
| ); | |
| } | |
| export { ContextProvider }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment