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

86
Views
conditionally render different method in react component based on URL

Im not too sure how to state this question (also not sure if there is a better way to achieve this) but--

I have a header component:

<header>
header
</header>

now I have 2 different pages that will be using different variations of the header component...

Currently, I have dry code where I have imported the header component into one of the pages, though into the other I have it hardcoded though the changes are edited...

I was wondering how I can do it like:

<header>
if('/'){
return header a
}else if('/settings'){
return header b
}
</header>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use router to specified URL and do conditional

    <header >
      {router.route === '/settings' ? (
      settings header
      ) : (
      default header
      )}
      <header/>

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!