由model来处理逻辑,route传递fun引用给component使用
effects: {
*pageChangeHandler({ payload: { page } }, { put, select }) {
// dispatch({ type: 'storeresult/fetch', payload: { page } });
// 需要走路由,直接走方法浏览器看不出地址变化
const keyword = yield select(state => state.storeresult.keyword);
yield put(routerRedux.push({
pathname: '/gitsearch/store/result',
query: { keyword, page },
}));
},
// 接受路由参数
function StoreResult({ dispatch, storeresult }) {
// 检索
const filterHandler = (title, filterkey) => filterkey === '' || title.indexOf(filterkey) >= 0;
// 翻页
// const pageChangeHandler = page => dispatch({
// type: 'storeresult/pageChangeHandler',
// payload: { page },
// });
const pageChangeHandler = (page) => {
dispatch({
type: 'storeresult/pageChangeHandler',
payload: { page },
});
};
return (
<div className={styles.normal}>
<StoreResultComponent
filterHandler={filterHandler}
pageChangeHandler={pageChangeHandler}
repos={storeresult}
/>
</div>