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

139
Views
Fill massive state with data obtained from hooks

I have a massive data that I can obtain only using third party hooks, for example: const data1 = useSmthHook(1) where 1 - index;

Lets imagine that we need an object of 100 values:

const data1 = useSmthHook(1)
const data2 = useSmthHook(2)
const data3 = useSmthHook(3)
...
const data100 = useSmthHook(100)

It would be great to get as final result object with all 100 values.

Solution with loop doesn't work because of hooks can't be triggered inside loops.

//does not work!
for (var i = 1; i < 101; i++) {
      const data = useSmthHook(i)
      ....
    }

I have only one idea (im sure a bad one) that works: create empty array, rendering 100 components, in Item component logic: while render get hook value => update global state with this data. So every new Item render causes +1 row (update) global state. 100 updates and 100 re-reneders.

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!