Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda