Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

两处疑问 #19

Closed
jasonwzw opened this issue Aug 18, 2018 · 1 comment
Closed

两处疑问 #19

jasonwzw opened this issue Aug 18, 2018 · 1 comment

Comments

@jasonwzw
Copy link

src/redux/reducers/counter.js

import {INCREMENT, DECREMENT, RESET} from '../actions/counter';

const initState = {
    count: 0
};

export default function reducer(state = initState, action) {
    switch (action.type) {
        case INCREMENT:
            return {
                count: state.count + 1
            };
        case DECREMENT:
            return {
                count: state.count - 1
            };
        case RESET:
            return {count: 0}; //这里是不是应该是 return 0
        default:
            return state
    }
}

如果reset返回的不是0而是一个对象,console的结果会是
{ counter: { count: 0 } }
{ counter: { count: 1 } }
{ counter: { count: 0 } }
{ counter: { count: { count: 0 } } }

webpack testRedux.js build.js
这里我这么写会报错,最后用的是 webpack testRedux.js -o build.js
是不是因为我用的webpack版本是4.16.5?所以不一样

@brickspert
Copy link
Owner

  1. 第一个问题 你试试就知道了呀~
  2. 第二个问题,是要webpack 3的。但是你没写具体的报错信息,不是很确定。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants