-
-
Save dedurus/a4bffbae658e4cbb6d021365b359fc3a to your computer and use it in GitHub Desktop.
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
import type { FunctionComponent } from "react"; | |
export const combineProviders = (providers: FunctionComponent[]) => providers.reduce( | |
(Combined, Provider) => ({ children }) => ( | |
<Combined> | |
<Provider>{children}</Provider> | |
</Combined> | |
), | |
); |
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
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