I have a react function and I am passing an array of objects as a prop. When the component renders, the array is nested into an object of the same name.
Why is it being nested? And can I do something to coerce it back to an array?
Here is the code (and a link to a pen (https://codepen.io/bluesixty/pen/PJQKVq?editors=0010):
const tags = [
{
name: 'ios',
link: '',
},
{
name: 'ANDROID',
link: '',
},
{
name: 'REACT',
link: '',
},
{
name: 'javascript',
link: '',
},
]
const App = tagList => {
return (
<div>
This is a React component!
<ul>
{tagList.tagList.map((tag, i) => (
<li>
{tag.name}
</li>
))}
</ul>
</div>
);
}
ReactDOM.render(
<App tagList={tags}/>,
document.getElementById('root')
);
Removing the second tagList in the .map fails with 'tagList.map is not a function'. Which is true, it is an object now????
{tagList.map((tag, i) => (