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

164
Visualizações
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 à 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