In code snippet below, console.log(el.distance) is equal to a string.
For one reason or the other, if I try to return el.distance react keeps throwing me the classic:
Error: Objects are not valid as a React child (found: object with keys {item, distance}). If you meant to render a collection of children, use an array instead.
return evtsFiltered?.map((item) => {
return (
<div>
Distance:
{distance?.find((el) => {
if (el.item === item._id) console.log(el.distance)
})}
</div>
)
})
How can?
I also tried putting it between html tags like so
return evtsFiltered?.map((item) => {
return (
<div>
Distance:
{distance?.find((el) => {
if (el.item === item._id) return <p> {el.distance} </p>
})}
</div>
)
})
Nothing works, please help!