Why get error when trying to use object spread?

0 like 0 dislike
39 views
const initialState = {a: 12, b: 13} export function searchReducer(state = initialState, action) { switch (action.type) { case(consts.SEARCH_INIT) : let test = {...state} console.log("--- action.payload", "test") return state default: return state } }
Code

Module build failed: SyntaxError: Unexpected token (8:15)
the error indicates the spread (...)
In the console of Chrome I tried and it works. What's the problem?
.baberlrc :
{ "presets": [ "env", "react", flow ], "plugins": [ "transform-class-properties" ] }
by | 39 views

1 Answer

0 like 0 dislike
npm i-S babel-preset-stage-0

{ "presets": [ "env", "stage-0", "react", flow ] }


transform-class-the properties can safely be cut, as stage-0 contains including its.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,911 users