为什么点击操作后 Redux reducer returns 未定义?

Why Redux reducer returns undefined after action click?

我有一个 React-table,我在其中传递来自 reducer 的 initialState 的数据,如下所示:

const getData = () => {
    return {
        data: [{},{},{}]
    }
}

const initialState = getData();

const ipReducer = (state = initialState, action) => {

    if (action.type === 'CHANGE_IP_STATUS') {
        let newState = Object.assign({}, state);
        return { newState }

    } else {
        return state;
    }
}

export default ipReducer;

getData() 将从服务器获取数据。

我在 table 行中有切换器,可以更改 table 数据状态。所以我执行一个 redux 操作来改变 table 的状态。但是当操作完成后 table table 得到 undefined 数据。

这是我的 table:

<div>
     <ReactTable
         data={this.props.data}
         columns={columns}
     />
</div>

这是我的状态道具图:

const mapStateToProps = (state) => ({
    data: state.ipTable.data,
})

console.log() 我看到我的 ipReducer returns 有效数据对象。但是为什么这个对象在更改状态执行后没有出现在我的 table 组件中?

而不是 returning return { newState } 你应该 return newState 因为它已经是一个从更新状态创建的对象

const ipReducer = (state = initialState, action) => {

    if (action.type === 'CHANGE_IP_STATUS') {
        let newState = Object.assign({}, state);
        return newState;

    } else {
        return state;
    }
}