Im trying to add a object to a sub objecto but I got some errors, some could help me? this is my code, thanks: Obs:I've used 'push' and got the error msg: push is not defined.
if(this.state.upd != '' && this.state.image1 == ''){
cadastro.imagens.push({1:this.state.img[1]?this.state.img[1]:""});
}else {
cadastro.imagens.push({1:this.state.image1});
}
And if I use like that it subscribe the others
if(this.state.upd != '' && this.state.image2 == ''){
cadastro.imagens = {2:this.state.img[2]?this.state.img[2]:""};
}else {
cadastro.imagens = {2:this.state.image2};
}
cadastrodata. Also, if you explain a little bit more about what are you trying to do here, it will be better.cadastrois? If it is in the state then assigning some properties means you are mutating the state and you shouldn't do that. Other than that manipulating objects is not so hard.