我无法将redux存储值获取到props,我签入了reducers、store、action和js文件,一切正常。但同时
将选择器传递给MapStateToprops。
误差
错误:uncaught(in promise)类型错误:对象(…)不是函数
at selectHosDeatilsResult (AddAppointment.js?0a10:319)
import React from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
class example extends React.PureComponent {
render() {
console.log('this.props', this.props);
return (
<div>
</div>
);
}
}
const selectHosDeatilsResult = () => createSelector(
makeHospitalResult(),
value => ({ value }),
);
const mapStateToProps = state => ({
details: selectDeatilsResult()(state),
});
export default connect(mapStateToProps, null)(example);
减速器代码
const initialState = fromJS({
hospitalResult: null,
});
export default function Reducer(state = initialState, action) {
switch (action.type) {
case HOSPITAL_SUCCESS:
return state.set('requesting', false).set('hospitalResult',action.payload);
default: return state;
}
}
选择器代码
import { createSelector } from 'reselect';
const SelectAppointment = (state) => state.get('appointments');
const makeHospitalResult = () => createSelector(
SelectAppointment,
(state) => state.get('hospitalResult')
);
最佳答案
如果您正在使用热重新加载,请确保重新启动开发服务器。我以前也遇到过这样的问题:)
关于javascript - 无法使用选择器从Redux存储中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57352865/