Last active
March 25, 2022 06:20
-
-
Save m5r/795b8575e9bd89e66f668c39853d47fc to your computer and use it in GitHub Desktop.
This file contains 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
import type { FunctionComponent } from "react"; | |
export const combineProviders = (providers: FunctionComponent[]) => providers.reduce( | |
(Combined, Provider) => ({ children }) => ( | |
<Combined> | |
<Provider>{children}</Provider> | |
</Combined> | |
), | |
); |
This file contains 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
import { BrowserRouter } from "react-router-dom"; | |
import { RecoilRoot } from "recoil"; | |
import { ApolloProvider } from "@apollo/client"; | |
import { combineProviders } from "./combine-provider"; | |
const Providers = combineProviders([ | |
BrowserRouter, | |
RecoilRoot, | |
ApolloProvider, | |
]); | |
function Root() { | |
return ( | |
<Providers> | |
<App /> | |
</Providers> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment