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

100
Views
How to control parent tabs & tab content from a child component links

https://codesandbox.io/s/simple-line-chart-forked-h39zlx?file=/src/App.tsx I wanted to load each main tab components from the loaded landing component above link. on click of the 3 tabs under overview, the overview component should replace with clicked tab's component and the main tab should active. please see codesandbox full code & help

const [active, setActive] = useState("tab1")
const isActive = (key) => (active === key ? 'active' : '');

 <a to="" className={`btn btn-link ${active === "tab1"? "active":""}`}    onClick={() => setActive("tab1")} >Overview</a> 
 <a to="" className={`btn btn-link ${active === "tab2"? "active":""}`}    onClick={() => setActive("tab2")} > Align & Ratio</a> 
 <a to="" className={`btn btn-link ${active === "tab3"? "active":""}`}    onClick={() => setActive("tab3")} > Avatar       </a>             
 <a to="" className={`btn btn-link ${active === "tab4"? "active":""}`}    onClick={() => setActive("tab4")} > Tags       </a> 

{active === "tab1" && <div><OverviewMain title="Overview" /></div>}
{active === "tab2" && <div><AlignandRatio title="AlignandRatio" /></div>}
{active === "tab3" && <div><Avatar title="Avatar"/></div>}
{active === "tab4" && <div><Tags title="Tags"/></div>}

How to load That links under overview by map ? if I have const Tabs=[ { tabname:"tab2", }, { tabname:"tab3", }, { tabname:"tab4", } ]

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 // Component Overview
  function Overview() {
    return (
      <div>
        <hr />
        <h1>Overview</h1>
        <a onClick={() => setActive("tab2")} className="tab">
          Align & Ratio{" "}
        </a>
        <a onClick={() => setActive("tab3")} className="tab">
          Avatar{" "}
        </a>
        <a onClick={() => setActive("tab4")} className="tab">
          Tags{" "}
        </a>
      </div>
    );
  }

Try this

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!