Skip to content

Tag: reactjs

Why won’t setMatrix([…matrix, [[x][y]]]) work?

I want to add the coordinates x and y (from the loop) to the state (matrix) like you can see in my example but it won’t work. Can someone help me? Answer The problem is in expression [x][y] which evaluates to undefined. [x] defines an array containing one element x [x][y] tries to index the [x] array, t…

Forwarding props from parent to child component

I have 2 components list of posts and when clicking on link on post card i’m entering into post. I can’t access props.postDetails in child component. When I console log the props, I have {history: {…}, location: {…}, match: {…}, staticContext: undefined} only this without props.postDetails. Can so…