2

嗨,我怎样才能从另一个减速器获得价值?

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

switch (action.type) {

    case CALC_BET_AMOUNT:

        function calcBetAmount(value) {

            switch (value) {

                case 'max':
                    return userReducer.user_balance;

                default:
                    return state;
            }

        }
    }
}

Return userReducer.user_balance - 应该返回一个存储在另一个 reducer 中的值

它是我的userReducer代码:

let initialState = {
    user_balance: 0
};
4

1 回答 1

0

你没有修改状态。减速器应该修改状态。这看起来更像是对状态的查询,您可能希望为此使用选择器。

于 2020-08-20T13:25:07.983 回答