Skip to content

Commit 43a8d12

Browse files
committed
added routing to buttons
1 parent 35fa9fc commit 43a8d12

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ function App() {
5151
<Alert alert={alert} />
5252
<div className="container my-3">
5353
<Routes>
54-
<Route path="/about" element={<About />} />
54+
<Route exact path="/about" element={<About />} />
5555
<Route
56+
exact
5657
path="/"
5758
element={
5859
<TextForm

src/componets/Navbar.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22
import PropTypes from "prop-types";
3+
import { Link } from "react-router-dom";
34

45
Navbar.propTypes = {
56
title: PropTypes.string.isRequired,
@@ -16,9 +17,9 @@ export default function Navbar(props) {
1617
<nav
1718
className={`navbar navbar-expand-lg navbar-${props.mode} bg-${props.mode}`}>
1819
<div className="container-fluid">
19-
<a className="navbar-brand" href="/">
20+
<Link className="navbar-brand" to="/">
2021
{props.title}
21-
</a>
22+
</Link>
2223
<button
2324
className="navbar-toggler"
2425
type="button"
@@ -34,17 +35,17 @@ export default function Navbar(props) {
3435
id="navbarSupportedContent">
3536
<ul className="navbar-nav me-auto mb-2 mb-lg-0">
3637
<li className="nav-item">
37-
<a
38+
<Link
3839
className="nav-link active"
3940
aria-current="page"
40-
href="/">
41+
to="/">
4142
Home
42-
</a>
43+
</Link>
4344
</li>
4445
<li className="nav-item">
45-
<a className="nav-link" href="/">
46+
<Link className="nav-link" to="/about">
4647
{props.aboutText}
47-
</a>
48+
</Link>
4849
</li>
4950
</ul>
5051
<div

0 commit comments

Comments
 (0)