Skip to content

Instantly share code, notes, and snippets.

Created November 3, 2019 12:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import React from "react";
import Todos from "./components/Todos";
import Login from "./components/Login";
import { TodoProvider } from "./contexts/TodoContext";
import { AuthProvider, useAuthContext, logout } from "./contexts/AuthContext";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import "./App.css";
function App() {
return (
<div className="App">
<Greeting />
<Route path="/todos">
<Todos />
<Route path="/">
<Login />
function Greeting() {
const { auth, dispatch } = useAuthContext();
if (auth.isLoggedIn)
return (
Hello, {}!
<button onClick={e => dispatch(logout())}>Logout</button>
return <p>You are not logged in</p>;
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment