我有一个小反应redux应用程序 和我在mapstatetoprops(工作)的状态 是网格的数据数组
const mapStateToProps = state => {
console.dirxml(state);
return {
work: state.work,
loading: state.loading
};
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
我用数据填充网格(在工作中), 在下一次调度之后(在不同组件中有不同的操作)“工作”变得未定义
这是减速器:
const initialState = {
Data: null,
work: [],
input: []
};
const rootReducer = (state = initialState, action) => {
console.info(action.type);
switch (action.type) {
case 'FETCH_BEGIN':
return {
state,
loading: true,
error: null
};
case Cons.INPUTDATA_CREATEJSON:
return {
state,
inputData: action.payload.input,
message: action.payload.message
}
case Cons.GETNAME:
state.Data = action.payload.item;
return {
state,
loading: false,
}
case Cons.FETCHWORK:
return {
state,
loading: false,
work: action.payload.items
}
case Cons.FETCH_ITEMS_SUCCESS:
return {
state,
loading: false,
items: action.payload.items
}
case Cons.FETCH_FAILURE:
return {
state,
loading: false,
error: action.payload.error,
items: []
};
default:
return state;
}
};
我可以在mapstatetoprops中看到更深层次状态的“工作”数据,但从更深层次的状态获取数据没有任何意义,所以我认为我的reducer有问题
答案 0 :(得分:0)