2

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 Answers1

0

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.

Ted Elliott
  • 2,925
  • 1
  • 23
  • 27
  • I agree with this - the selector should be made available to the component. If you're desperate to add it to another state, then you'll need to provide it through the action payload – Nick Howard Aug 20 '20 at 13:27