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

174
Views
React callback return not iterable instance

I'm using ant-desing(v3.26.14) List component in React. Normally if I try to pass plain array to 'dataSource' property then everything is fine. But when I try to pass array via callback it's given error.

<List dataSource={someArray} /> //is fine
<List dataSource={() => someArray} /> //getting error

Error: 'TypeError: Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a Symbol.iterator method.'

I wonder is this normal behaviour of javascript or some library issue and why that's happening, isn't this the same thing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think it's because the List component is expecting the array so it can use the spread, but you are giving it a callback function. It doesn't expect a callback function but an iterator ( array in this case ).

about 4 years ago · Juan Pablo Isaza Report
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!