i try to repeat the example: https://github.com/reduxjs/redux/tree/master/examples/async/src
But i use last versions of React
, Redux
and Babel
(in example was React v15.5). I don't change anything in this example, and then i try to build it with webpack i get SyntaxError here:
22 | case INVALIDATE_SUBREDDIT:
23 | return {
> 24 | ...state,
| ^
25 | didInvalidate: true
26 | }
In the ./reducers/index.js
const posts = (state = {
isFetching: false,
didInvalidate: false,
items: []
}, action) => {
switch (action.type) {
case INVALIDATE_SUBREDDIT:
return {
...state,
didInvalidate: true
}
case REQUEST_POSTS:
return {
...state,
isFetching: true,
didInvalidate: false
}
case RECEIVE_POSTS:
return {
...state,
isFetching: false,
didInvalidate: false,
items: action.posts,
lastUpdated: action.receivedAt
}
default:
return state
}
}
What is wrong here?
UPDATE:
After AdityaParab answer i make:
npm install --save-dev babel-preset-stage-3
And in your .babelrc
{
"presets": ["env", "stage-3", "react"]
}
Last error disappeared, but i take one more in ./containers/App.js
:
19 | }
20 |
> 21 | handleChange = nextSubreddit => {
| ^
22 | this.props.dispatch(selectSubreddit(nextSubreddit))
23 | }
24 |
UPDATE 2:
Works fine with it.
{
"presets": ["env", "stage-3", "react"],
"plugins": ["transform-object-rest-spread", "transform-decorators-legacy", "transform-class-properties"]
}
Thanks all for advice!