Skip to content

Instantly share code, notes, and snippets.

@PrincewillIroka
Last active December 31, 2020 20:35
Show Gist options
  • Save PrincewillIroka/f4491b995889bc67437fc75670c00c47 to your computer and use it in GitHub Desktop.
Save PrincewillIroka/f4491b995889bc67437fc75670c00c47 to your computer and use it in GitHub Desktop.
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