I want to pass an array of objects as a prop of a component here's the array :
var champs = [
{ label: "coucou" },
{ label: "yo" }
]
and I pass it within my component like this :
<GererInformations champs={champs} />
below : the code of the GereInformations component :
class GererInformations extends React.Component {
render() {
console.log(this.props);
Array.from(this.props.champs).map(champ => {
var id = uuidv4();
return (
<div>
<label htmlFor={id}>{champ.label}</label>
<input id={id} type="text" />
</div>
)
})
return (
this.props.champs
);
}
}
I have the error : Objects are not valid as a React child (found: object with keys {label}). If you meant to render a collection of children, use an array instead.