Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

99
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda