I have a problem in mapping an array in React, Here is the problem : this is my state of the parent element :
this.state = {
grouping: 3,
bars: [{
snare: Array(16).fill('0'),
hihat: Array(16).fill('0'),
kick: Array(16).fill('0'),
}]
}
i wanna pass the bars to the child element same this :
<Bar bar={this.state.bars}>
and in 'Bar' class i write this code :
class Bar extends Component {
render(){
const Bars = this.props.bars.map((bar)=>{
return('something')
}
return({Bars})
}
}
after this codes this error occurs to me :
Objects are not valid as a React child (found: object with keys {Bars}). If you meant to render a collection of children, use an array instead.
help me, please
return({Bars})so,{}makes it an object.return (<div>Bars</div>)instead