React. get state from another reducer

Viewed 73

Hi how can i get the value from another reducer?

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 - should return a value which is stored in another reducer

Its my userReducer code:

let initialState = {
    user_balance: 0
};
1 Answers

You're not modifying state. Reducers should modify state. This looks more like a query on the state, you would want to use a selector for that.

Related