Reputation: 189
jsx transforming tool throws an error saying 'unexpected token: [' on the following line:
this.setState({array[index]: value});
Obviously I want simply to set new state but this error forced me to write some workarounds. Why isn't the transformer accepting the above line?
Upvotes: 1
Views: 88
Reputation: 22933
Simply because it's not valid Javascript (or JSX for that matter). You want something like this:
array[index] = value;
this.setState({array: array});
Upvotes: 5