I am using React state to save some data. For ints and strings, it works well, but unfortunately arrays do not work.
In my component constructor, I have
constructor(props) { super(props); this.state = { terms: 5, myArray: [] }
and then, I try to save it in the DidUpdate component
componentDidUpdate() { this.state = { terms: this.state.terms, myArray: this.state.myArray }
but myArray: this.state.myArray does not work. However, terms: this.state.terms works fine.
Can someone help!
source share