使用react redux reducer最终会阻止浏览器

时间:2017-02-02 00:21:51

标签: javascript reactjs redux react-redux

所以我有这段代码

const changeCategory = (state = {}, action) => {
  return Object.assign({}, state,
    {
      activeCategory: 1
    }
  );
}


function daReducer(state = {}, action){
  switch(action.type){
    case 'CHANGE_CATEGORY':
      return changeCategory(state, action);
    default:
      return state;
  }
}

export default daReducer;

和另一个jsx

let store = createStore(daReducer, initialState);

render(<Provider store={store}><da/></Provider>, document.getElementById('app'));

正常工作

但是如果我将activeCategory的值修改为对象:

const changeCategory = (state = {}, action) => {
  return Object.assign({}, state,
    {
      activeCategory: {id: 1}
    }
  );
}

在Firefox中运行它最终返回“警告无响应脚本”错误

为什么会发生这种情况,我该如何解决?

0 个答案:

没有答案