I don't really know how to explain this so I will explain in code
const selectedId = props.match.params.id;
console.log(selectedId);
The above code prints the correct value for e.g if im on products/2 it prints 2, if I'm on products/3 it prints 3 and so on.
const product = data.products.find((x) => x._id === 1);
console.log(product);
Now I have a data array and I am using .find and as you can see x._id === 1, it prints the correct details for object 1 within the array.
const selectedId = props.match.params.id;
const product = data.products.find((x) => x._id === selectedId);
console.log(product);
This prints undefined, if I had to console log selectedId it prints the correct id but when passing it through the find function it returns undefined.
Any help is appreciated thanks