Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!