TypeError when mapping nodeList

Viewed 29

so I'm trying to map the data from a List into a array in ReactJS. I was working for a bit and then out of nowhere I started getting the Error: TypeError: nodesList.map is not a function

I saw that it is possible to also use Array.from() since nodeLists technically can't be mapped? This however doesn't work for me, instead I then get the error: TypeError: Cannot read properties of undefined (reading 'source')

Does anyone have an Idea why it was working and isn't any more, or maybe a way to fix it?

const changes = { nodes: [], links: [] }
const orderList = nodesList.map(node => ({
        source: node,
        target: []
    }));

using Array.from():

const orderList = Array.from(nodesList, node => ({
        source: node,
        target: []
    }));
0 Answers
Related