简体   繁体   中英

React. get state from another reducer

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
};

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM