scwebd
1/23/2019 - 7:21 AM

pupsterNav

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a class="navbar-brand" href="/">Pupster</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
            <li class="nav-link">
                <a class="nav-link" href="/">About</a>
            </li>
            <li class="nav-link">
                <a class="nav-link" href="/discover">Discover</a>
            </li>
            <li class="nav-link">
                <a class="nav-link" href="/search">Search</a>
            </li>
        </ul>
    </div>
</nav>
import React from "react";
import { Link, NavLink } from "react-router-dom";

const NavBar = () => {
    return (
        <nav className="navbar navbar-expand-lg navbar-dark bg-dark">
            <Link className="navbar-brand" to="/">Pupster</Link>
            <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span className="navbar-toggler-icon"></span>
            </button>
            <div className="collapse navbar-collapse" id="navbarNav">
                <ul className="navbar-nav">
                    <li>
                        <NavLink 
                            activeClassName="active"
                            className="nav-link" 
                            isActive={() => window.location.pathname === "/" || window.location.pathname === "/about"}
                            to="/"
                        >
                            About
                        </NavLink>
                    </li>
                    <li>
                        <NavLink 
                            activeClassName="active"
                            className="nav-link" 
                            to="/discover"
                        >
                            Discover
                        </NavLink>
                    </li>
                    <li>
                        <NavLink 
                            activeClassName="active"
                            className="nav-link"
                            to="/search"
                        >
                            Search
                        </NavLink>
                    </li>
                </ul>
            </div>
        </nav>
    )
}

export default NavBar;