Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
Reactjs hide navbar in all component have path = /admin/

i want to hide my navbar when i'm in all page have path='/admin/...' but it's so length. How can i clean it, thank very much.

let HideHeader = window.location.pathname === '/admin/info' && '/admin/setting' && '/admin/post' && '/admin/messange' ? null : <MyNav username={username} />
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can use indexOf:

let HideHeader = window.location.pathname.indexOf('/admin/') === 0 ? null : <MyNav username={username} />

It will test for pathname that starts with /admin/

about 4 years ago · Juan Pablo Isaza Report

0

Try to use includes() method:

let HideHeader = window.location.pathname.includes('/admin/') ? null : <MyNav username={username} />

about 4 years ago · Juan Pablo Isaza Report

0

You can use match method with regex

let HideHeader =  !window.location.pathname.match(/\/admin.*/g) && <MyNav username={username} />
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!