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

217
Vistas
How do I pass a component reference to another component?

I have two components Grid and Filter, I need to link these two components. That is, pass the Grid link to the Filter. The link to the Grid in the Filter is needed in order to be able to tell the filter which grid to work with.

App.js:

  return (
    <div>
      <Grid ref={ref1}.../>
      <Filter gridRef={ref1}.../>
      <.../>
    </div>
  )

What do I need to do?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You will have to make the grid a frowardRef component. Understand forwardRef components.

Next, create a ref (let say rfGrid) with useRef hook in the parent component. Pass rfGrid to the ref prop of the Grid component and pass rfGrid to the gridRef prop of the Filter component.

import React, { useRef } from 'react';

const Parent = () => {
    const rfGrid = useRef();

    return (
        <div>
            <Grid ref={rfGrid} />
            <Filter gridRef={rfGrid} />
        </div>
    );
};
about 4 years ago · Juan Pablo Isaza Denunciar
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