React table getting issue TypeError: Cannot read property 'forEach' of undefined
Asked Answered
V

3

7

Since today morning we are getting below issue, After building latest node_modules :

**methods.js?ab36:59 Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined

at ReactTable.getDataModel (methods.js?ab36:59)

Vagrom answered 4/12, 2019 at 14:53 Comment(3)
Full Error details : methods.js?ab36:59 Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined at ReactTable.getDataModel (methods.js?ab36:59) at ReactTable._class (lifecycle.js?aa71:18) at ReactTable._class (methods.js?ab36:27) at new ReactTable (index.js?370e:30) at constructClassInstance (VM376323 react-dom.development.js:14204) at updateClassComponent (VM376323 react-dom.development.js:18413) at beginWork$1 (VM376323 react-dom.development.js:20186) at HTMLUnknownElement.callCallback (VM376323 react-dom.developmentVagrom
Please edit the question with the full error details, including proper formatting. It's much easier to read that way.Maim
show a piece of failed codeWendelin
M
28

Example:

You should do something like this:

useTable({ columns, data: tableData }) // must be data
Mayers answered 4/2, 2021 at 0:21 Comment(2)
We don't allow images of text (code/input/output/errors, or otherwise) on Stack Overflow. Please post your answer as (formatted) code only. To understand why, check out this post on the Meta Stack Overflow site. Though it focuses on the perspective of asking questions, it also applies to answers as well.Lizzettelizzie
Aaarrrggghh, this has cost me days - thanks :-)Culvert
C
2

Look at this: https://github.com/tannerlinsley/react-table/issues/1686 and try a downgrade.

P.S. Please be more accurate on your questions

Cholecystitis answered 4/12, 2019 at 16:25 Comment(0)
B
0

I had this error. In my case, the fix was much simpler than those suggested the above. React-table MUST be given a list. My fetch (GET request) was returning an object which I did not anticipate. React-table needs a list to iterate over, NOT an object. An array/list of objects is a list.

The fix was to use [ ] around the fetched object because this made it a list of a single object. React-table could then iterate over this list.

For example, React-table can't iterate over the following object:

{key1:pair1}

But it CAN iterate over this similar array containing one object, notice the square brackets:

[{key1:pair1}]

Blowout answered 13/7, 2023 at 15:16 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Obvolute

© 2022 - 2025 — McMap. All rights reserved.