From 4c8ef953e57418cd36036678c19e40b39253ae69 Mon Sep 17 00:00:00 2001 From: JoeyKo Date: Thu, 6 Sep 2018 14:28:04 +0800 Subject: [PATCH] fix fetchMore --- src/models/list.js | 13 +++++++++++++ src/pages/List/Articles.js | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/models/list.js b/src/models/list.js index 06d25a93..4758edaa 100644 --- a/src/models/list.js +++ b/src/models/list.js @@ -15,6 +15,13 @@ export default { payload: Array.isArray(response) ? response : [], }); }, + *appendFetch({ payload }, { call, put }) { + const response = yield call(queryFakeList, payload); + yield put({ + type: 'appendList', + payload: Array.isArray(response) ? response : [], + }); + }, *submit({ payload }, { call, put }) { let callback; if (payload.id) { @@ -37,5 +44,11 @@ export default { list: action.payload, }; }, + appendList(state, action) { + return { + ...state, + list: state.list.concat(action.payload), + }; + }, }, }; diff --git a/src/pages/List/Articles.js b/src/pages/List/Articles.js index 0aec03c8..815e79cc 100644 --- a/src/pages/List/Articles.js +++ b/src/pages/List/Articles.js @@ -19,7 +19,13 @@ const pageSize = 5; })) class SearchList extends Component { componentDidMount() { - this.fetchMore(); + const { dispatch } = this.props; + dispatch({ + type: 'list/fetch', + payload: { + count: 5, + }, + }); } setOwner = () => { -- GitLab