Cannot display table using React
Hi,
I am trying to display a simple table but it is showing me error. Been stuck on this for two weeks.
Here is my code on codesandbox: https://codesandbox.io/s/angry-gauss-lvsrn3?file=/src/App.js
Embedding it here too:
The error:
userArranged[0].map is not a function
Can someone help me out please?4 Replies
{ product: products[i], counts: counts[i] }
is an Object and non-array objects don't have Array.prototype.map()
you are not using counts
in the returned value, so no idea what you are trying to achieve to help with a solution ¯\_(ツ)_/¯
for a general advice for debugging, I recommend to log any value that looks suspicious (when you believe it should be something, but the error message sounds like it's something else), e.g. console.log(userArranged[0])
Thanks for replying. I just want a table with Products and Counts as two columns with their respective values under them.
Products Counts
A 3
B 4
C 6
I also tried
userArranged.push([products, counts])
to have a different array but it gave me two rows, first one filled with all products and second one with all counts.Solution
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Thank you so much. This did it. Much obliged!