I've found this code in some tutorial. How does it work? Why isn't it working for me (I get SyntaxError: Unexpected token ...
)?
const commentReducer = (state, action) => {
return {
...state, //error on this line
completed: !state.completed
}
}
This code is using object spread properties, which are not a part of ECMAScript 6. They are currently an ECMAScript proposal at stage 3. To use them, you have to configure Babel to use stage-3
preset.