Last active
December 31, 2020 20:35
-
-
Save PrincewillIroka/f4491b995889bc67437fc75670c00c47 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 React, { createContext, useReducer } from 'react'; | |
import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; | |
import Home from "./components/Home"; | |
import Login from "./components/Login"; | |
import { initialState, reducer } from "./store/reducer"; | |
export const AuthContext = createContext(); | |
function App() { | |
const [state, dispatch] = useReducer(reducer, initialState); | |
return ( | |
<AuthContext.Provider | |
value={{ | |
state, | |
dispatch | |
}} | |
> | |
<Router> | |
<Switch> | |
<Route path="/login" component={Login}/> | |
<Route path="/" component={Home}/> | |
</Switch> | |
</Router> | |
</AuthContext.Provider> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment