[英]React. get state 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 - 应该返回一个存储在另一个 reducer 中的值
它是我的userReducer代码:
let initialState = {
user_balance: 0
};
您没有修改 state。 减速器应修改 state。 这看起来更像是对 state 的查询,您可能需要为此使用选择器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.