sac*_*abu 8 javascript reactjs redux-saga
我无法将redux存储值获取到props,我检查了reducers,store,action和JS文件,一切正常。但是,同时将选择器传递给mapStateToProps。
错误

错误:未捕获(承诺)TypeError:Object(...)不是函数
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);
Run Code Online (Sandbox Code Playgroud)
减速器代码
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;
}
}
Run Code Online (Sandbox Code Playgroud)
选择器代码
import { createSelector } from 'reselect';
const SelectAppointment = (state) => state.get('appointments');
const makeHospitalResult = () => createSelector(
SelectAppointment,
(state) => state.get('hospitalResult')
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
74 次 |
| 最近记录: |