import React from "react"; import { ApolloProvider } from "@apollo/client"; import { Auth0Provider } from "@auth0/auth0-react"; import { CSSReset, ChakraProvider } from "@chakra-ui/core"; import defaultTheme from "@chakra-ui/theme"; import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; import loadable from "@loadable/component"; import { useAuth0 } from "@auth0/auth0-react"; import buildApolloClient from "./apolloClient"; import PageLayout from "./PageLayout"; const ItemsPage = loadable(() => import("./ItemsPage")); const HomePage = loadable(() => import("./HomePage")); const ModelingPage = loadable(() => import("./ModelingPage")); const WardrobePage = loadable(() => import("./WardrobePage")); const theme = { ...defaultTheme, styles: { ...defaultTheme.styles, global: ({ colorMode, ...rest }) => ({ ...defaultTheme.styles.global({ colorMode, ...rest }), color: colorMode === "light" ? "green.800" : "green.50", transition: "all 0.25s", }), }, }; /** * App is the entry point of our application. There's not a ton of exciting * stuff happening here, mostly just setting up some globals and theming! * * To really dive into the code, try going down into a page component! */ function App() { return ( ); } function ApolloProviderWithAuth0({ children }) { const auth0 = useAuth0(); const auth0Ref = React.useRef(auth0); React.useEffect(() => { auth0Ref.current = auth0; }, [auth0]); const client = React.useMemo( () => buildApolloClient(() => auth0Ref.current), [] ); return {children}; } export default App;