Please help me. I don't know why this piece of code doesn't work.
It gives me an error: "Objects are not valid as a React child (found: object with keys {itemss}). If you meant to render a collection of children, use an array instead." Why {i.title} is an object. It's just a string. How can i fix this? and How actually I can iterate nested objects?
class ShopItem extends React.Component {
render() {
var items = [
{
link: 'first link',
title: 'Emery NEM XF',
price: '$950'
},
{
link: 'second link',
title: 'Emery NEM XF',
price: '$950'
},
{
link: 'third link',
title: 'Emery NEM XF',
price: '$950'
}
];
const item = items.map((i) =>{
return ( <h1>{i.title}</h1> )
});
return (
{items}
)
}
}
ReactDOM.render(<ShopItem /> , document.querySelector('#root'));
{i.title}
);` — or drop the parentheses all together and use `return{i.title}
; – Daniel Apt May 08 '18 at 10:02{i.title}
) but it's still not working. – Alexander May 08 '18 at 10:13