I am using the .map() function in the exact same way as in other projects, but on the one I am currently working on, it's throwing me this error: Error: Objects are not valid as a React child (found: object with keys {id, title}). If you meant to render a collection of children, use an array instead.
This is my code (the structure of which has worked in other projects as I mentioned):
import React from "react";
import Carousel from "react-elastic-carousel";
const Slider = () => {
let items = [
{id: 1, title: 'item #1'},
{id: 2, title: 'item #2'},
{id: 3, title: 'item #3'}
]
return (
<div>
<div>
<Carousel>
{items.map((item) => (
<div key={item}>{item}</div>
))}
</Carousel>
</div>
</div>
);
}
export default Slider;
I am wondering if it has to do with the fact that I am mapping inside of a component imported from an external library.
I have also tried adding an index to .map(item, index)
and that didn't work either.