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

95
Views
Passing Data Down to a Child Component

I'm making a smooth scroll menu. The menu is a component and therefore in a seperate jsx file.

It looks like below:

const SideTabs = (props) => {

    const [value, setValue] = React.useState(0);

    const handleChange = (event, newValue) => {
      setValue(newValue);
    };

    console.log(value)

  return (
    <IconContainer>
            <Tabs
            orientation="vertical" //change
            value={value}
            onChange={handleChange}
        >

            <Tab icon={<SearchIcon />} label={value === 0 ? <Typography variant="subtitle3">Search</Typography>: ""}/>

            <Tab icon={<WorkIcon />} label={value === 1 ? <Typography variant="subtitle3">Role</Typography>: ""}/>

            <Tab icon={<AccountBoxIcon/>} label={value === 2 ? <Typography variant="subtitle3">People</Typography>: ""} />
            
            <Tab icon={<ViewCompactIcon/>} label={value === 3 ? <Typography variant="subtitle3">Build</Typography> : ""} />
        </Tabs>
    </IconContainer>
  )
};

However, I want it to smooth scroll using the id's from this.

const JobPost = () => {

    const [value, setValue] = React.useState(0);

    const handleChange = (event, newValue) => {
      setValue(newValue);
    };


  return (
      <PageDiv>
          <IconContainer>
            <SideTabs/>
          </IconContainer>

          <Navbar/>
        <InitialSearch_INPUT id="search"/>
        <Tstdiv id="role">
            hello
        </Tstdiv>
        <Tstdiv2 id="people">
            Hi
        </Tstdiv2>
        <Tstdiv3 id="build">
            Hell1
        </Tstdiv3>
      </PageDiv>
);
};

I will then link it internally from the original file using react scroll, similar to this:

<Link to="role" spy={true} smooth={true} offset={-40} duration={500}>
                    <Tab icon={<WorkIcon />} label={value === 0 ? <Typography variant="subtitle3">Role</Typography>: ""}/>
                </Link>

the reason why I can't do the above alone is because I need to set the value using React state AND scroll.

I am not sure how to do this but I believe it requires props.

Any ideas!

Regards

about 4 years ago · Juan Pablo Isaza
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!