Skip to content

Commit

Permalink
修改了reducers中stores.js
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeBooo committed Feb 4, 2018
1 parent 1e3e270 commit 3a8a4c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/components/OrderList/Item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const Item = props => {
<button>评价</button>
</div>
</div>

);
};

Expand Down
5 changes: 3 additions & 2 deletions src/reducers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default function store(state = initialState, action) {
case actionTypes.STORE_UPDATE:
return action.data;
case actionTypes.STORE_ADD:
state.unshift(action.data); // 放在最前面
return state;
// 下面这种写法是错误的,因为state应该是只读的,不能直接修改state
// state.unshift(action.data); // 放在最前面
return [action.data, ...state];
case actionTypes.STORE_RM:
const newState = state.filter(item => {
return item.id !== action.data.id;
Expand Down

0 comments on commit 3a8a4c9

Please sign in to comment.