what is currentNodeData
in your case?
lets review:
So we have an Array inside the array.
Lets name it :
const innerArray = [{id:1}, {id: 2}, {id: 3}, {id: 4}]
const outer = [innerArray];
the outer array will have only one inner array?
if yes:
we can do the next thing:
outer[0].length // 4
or we can use flat()
outer.flat().length // 4
const innerArray = [{id:1}, {id: 2}, {id: 3}, {id: 4}]
const outer = [innerArray];
console.log(outer[0].length);
console.log(outer.flat().length);
Also we should understand that your variable can be assigned asynchronously, and in this case your varibale could be empty at the time when you try to get the length.
Let's try to reproduce:
In this example, we can see an error, because data is not assigned yet
let outer = [];
setTimeout(() => {outer = [[{id:1}]]}, 1000)
console.log(outer[0].length)
in this case we should add Optional chaining operator
or ?.
And at the first time we will see undefined, and when data is assigned we should check it again, and we will see length
let outer = [];
setTimeout(() => {outer = [[{id:1}]]}, 1000)
console.log(outer[0]?.length)
setTimeout(() => {console.log(outer[0]?.length)}, 1000)