I'm using Optional chaining operator which should solve this error, but in my loop allLinks.length i'm getting Object is possibly 'undefined'.ts(2532)
(my code works fine, just want to get rid of this error.)
i can fix it like this but its not right way :
const allLinks : any = props.Data?.nodes;
any suggestion is appreciated.
what am I doing wrong here ?
const allLinks = props.Data?.nodes;
for (let i = 0; i < allLinks?.length; i++) {
if (
allLinks?.[i].source == currentCam.id
) {
dispatch(linkById(allLinks?.[i].id));
}
}