Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

next js active link

import Link from "next/link";
import { useRouter } from "next/router";


export const MyNav = () => {

  const router = useRouter();

  return (
    <ul>
      <li className={router.pathname == "/" ? "active" : ""}>
        <Link href="/">home</Link>
      </li>
      <li className={router.pathname == "/about" ? "active" : ""}>
        <Link href="/about">about</Link>
      </li>
    </ul>
  );
};
Comment

next js active nav link

import Link from "next/link";
import { useRouter } from "next/router";


export const MyNav = () => {

  const router = useRouter();

  return (
    <ul>
      <li className={router.asPath == "/#about" ? "active" : ""}>
        <Link href="#about">about</Link>
      </li>
    </ul>
  );
}`;
Comment

PREVIOUS NEXT
Code Example
Javascript :: js write to json file 
Javascript :: protractor move mouse and click 
Javascript :: Get current active sheet name google appscript 
Javascript :: fibonacci series in javascript 
Javascript :: express.json vs bodyparser.json 
Javascript :: copy text to clipboard javascript react 
Javascript :: fetch bearer token 
Javascript :: js reduce concat numbers 
Javascript :: javascript hasownproperty 
Javascript :: for key value in object javascript 
Javascript :: how to refresh the page using react 
Javascript :: remove item jquery 
Javascript :: js delete element by id 
Javascript :: javascript after dom ready 
Javascript :: javascript array unique values 
Javascript :: window.ReactNativeWebView.postMessage 
Javascript :: for each element in obj js 
Javascript :: jqeury cdn 
Javascript :: BROWSER=none npm start exited with code 1 
Javascript :: DNA Pairing solution 
Javascript :: js add week to date 
Javascript :: truncate function react 
Javascript :: exceljs column pick from drop down list 
Javascript :: adonis order by relation 
Javascript :: react native center text vertically full screen 
Javascript :: how to get id of parent element in jquery 
Javascript :: install nodejs ubuntu 19.04 
Javascript :: regex exec fails twice 
Javascript :: Fancybox 2 show error image when not having any image 
Javascript :: discord.js join voice channel 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =