I am at component props and I want to get a state element of the class. But when I call this.state it is returning undefined
. Here is the code:
<div>
{this.addRestricao().map((el, i) => (
<Restricao
key={i}
getArray={array => {
debugger;
// if (i === 0) {
// this.setState({ matrizRestricoes: [] });
// }
let matrizRestr = this.state.matrizRestricoes;
matrizRestr[matrizRestr.length] = array;
this.setState({ matrizRestricoes: matrizRestr });
}}
/>
))}
</div>
How can I access the state value?
Comments
Post a Comment