Issue
I am using Typescript 1.7 and React 0.14 with the new ES6 systax and I'm having the following destructuring assignment, as explained here as well.
let x0, x1, y0, y1;
if(this.props.viewport) {
{x0, x1, y0, y1} = this.props.viewport;
}
However, I'm getting the Declaration or statement expected
error. What am I doing wrong?
Thanks
Solution
So, I found the problem. Had to wrap the whole line in parenthesis. So the following is correct.
let x0, x1, y0, y1;
if(this.props.viewport) {
({x0, x1, y0, y1} = this.props.viewport);
}
Answered By - XeniaSis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.