Search code examples
javascriptreactjssetstate

How to access numbered state in rect


Is any way to access numbered state. for eg

this.setState({123:hello})

now how can i access this state

console.log(this.state.123)  //this will show error

Solution

  • You could do the following:

    this.state[123]

    You should not use numbers as a object property name however.