English 中文(简体)
I want to condition the output with the url. At localhost:3000/admin navbar should should be different
原标题:

Navbar should be different in else condition but only if condition is working

function navbar() {
  const router = useRouter();

  if (router.pathname ===  /admin ) {
    return <section className="text-xl font-GreatVibes">Trrinket</section>;
  } else
    return (
      <Fragment>
        <section className="hidden lg1024:block z-30 mx-8">
          <div className="flex items-center justify-between">
            <NavBarLinks />
            <NavbarLogo />
            <NavBarControls />
            {/* <NavBarSearch /> */}
          </div>
        </section>
        <section className="lg1024:hidden">
          <div className="standalone:h-16">
            <NavBarLogoMobile />
            <NavBarMobile />
          </div>
        </section>
      </Fragment>
    );
}
export default navbar;

Different URLs as mentioned

最佳回答

use pathname with react

comapre your page with === includes()

问题回答

暂无回答




相关问题
How to use one react app into another react app?

I have two react apps, parent app and child app. and child app have an hash router. I have build the child app using npm run build, It creates build folder. That build folder moved into inside the ...

how to get selected value in Ant Design

I want to print the selected value, and below is my option list: const vesselName = [ { value: 0 , label: ALBIDDA , }, { value: 1 , label: ALRUMEILA , }, { value: 2 ,...

How to add a <br> tag in reactjs between two strings?

I am using react. I want to add a line break <br> between strings No results and Please try another search term. . I have tried No results.<br>Please try another search term. but ...

热门标签