Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 9, 2021 06:33
Show Gist options
  • Save percybolmer/587fb95d992647d902152ed520bb790c to your computer and use it in GitHub Desktop.
Save percybolmer/587fb95d992647d902152ed520bb790c to your computer and use it in GitHub Desktop.
import { NavLink , useHistory} from "react-router-dom";
function Navbar() {
let history = useHistory();
function goHome(path) {
history.push("/");
}
return (
<div className="navbar">
<button type="button" onClick={goHome}><h1>Navbar</h1></button>
<ul>
<li><NavLink exact to="/">Home</NavLink></li>
<li><NavLink to="/contact">Contact</NavLink></li>
<li><NavLink to="/about">About</NavLink></li>
<li><NavLink to={{
pathname: "/profile/percybolmer",
state: { registrationdate: "2021-07-07" },
}}>Profile</NavLink></li>
</ul>
</div>
)
}
export default Navbar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment