Skip to content

Instantly share code, notes, and snippets.

@ryanjyost
Created January 4, 2020 23:17
Show Gist options
  • Save ryanjyost/57b315d2c17b9a68f5779883639e5882 to your computer and use it in GitHub Desktop.
Save ryanjyost/57b315d2c17b9a68f5779883639e5882 to your computer and use it in GitHub Desktop.
Example 13
import React from "react";
import { Link, useHistory } from "react-router-dom";
import ROUTES, { RenderRoutes } from "./routes";
function App() {
const history = useHistory();
function logout() {
localStorage.removeItem("user");
history.push("/");
}
return (
<div style={{ display: "flex", height: "100vh", alignItems: "stretch" }}>
<div style={{ flex: 0.3, backgroundColor: "#f2f2f2" }}>
{displayRouteMenu(ROUTES)}
<button onClick={logout}>Log Out</button>
</div>
<div>
<RenderRoutes routes={ROUTES} />
</div>
</div>
);
}
export default App;
//... same stuff below
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment