Skip to content

Instantly share code, notes, and snippets.

@pubudu-ranasinghe
Created November 3, 2019 11:31
Show Gist options
  • Save pubudu-ranasinghe/d4e9c13f7312886299a6354ab648fedf to your computer and use it in GitHub Desktop.
Save pubudu-ranasinghe/d4e9c13f7312886299a6354ab648fedf to your computer and use it in GitHub Desktop.
react-context-example-15
import React from "react";
import Todos from "./components/Todos";
import Login from "./components/Login";
import { TodoProvider } from "./contexts/TodoContext";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import "./App.css";
function App() {
return (
<Router>
<div className="App">
<Greeting />
<Switch>
<Route path="/todos">
<TodoProvider>
<Todos />
</TodoProvider>
</Route>
<Route path="/">
<Login />
</Route>
</Switch>
</div>
</Router>
);
}
function Greeting() {
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