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

157
Vistas
firebase pass data to outside variable react typescript

I am trying to pass some data to a variable in react + typescript here is what I am trying

    const data = useMemo<DummyDataType[]>(
    () => [
      {
        userId: "Foo",
        flowAmount: "Bar",
      },

    ],
    []
  );

 const arr: { userId: string; flowAmount: string }[] = [];


 var leadsRef = db.ref('users');
leadsRef.on('value', function(snapshot) {

  snapshot.forEach(item => { 
    arr.push({userId: 'test', flowAmount: 'test'})
  })

}); 



  const Table = useTable<DummyDataType>({
    columns: columns,
    data: data,
    isDataLoading: false,
    isDataLoadingError: false,
    isRowSelectable: false,
    isMultiRowSelectable: false,
  });
  return (
    <Box p="4" color="white" bg="rgb(35, 36, 41)">
        <Button colorScheme='yellow' > Save changes</Button>
      {Table}
    </Box>
  );

so I want to push the arr to the data variable (the arr is just some dummy thing for me to test, i need the arr to reach the data var) now the problem is that the table loads before the firebase loads, and it does not render the arr. I think i need to change the data or the arr to some useState but I am not sure how that would work out If I use useState

type DummyDataType = {
  userId: ReactNode;
  flowAmount: ReactNode;

};
    const data = useState<DummyDataType[]>(
    () => [
      {
        userId: "Foo",
        flowAmount: "Bar",
      },


    ],
    []
  );

I get the next error enter image description here

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