MCPcopy
hub / github.com/reduxjs/redux / updatePagination

Function updatePagination

examples/real-world/src/reducers/paginate.js:18–46  ·  view source on GitHub ↗
(state = {
    isFetching: false,
    nextPageUrl: undefined,
    pageCount: 0,
    ids: []
  }, action)

Source from the content-addressed store, hash-verified

16 const [ requestType, successType, failureType ] = types
17
18 const updatePagination = (state = {
19 isFetching: false,
20 nextPageUrl: undefined,
21 pageCount: 0,
22 ids: []
23 }, action) => {
24 switch (action.type) {
25 case requestType:
26 return {
27 ...state,
28 isFetching: true
29 }
30 case successType:
31 return {
32 ...state,
33 isFetching: false,
34 ids: union(state.ids, action.response.result),
35 nextPageUrl: action.response.nextPageUrl,
36 pageCount: state.pageCount + 1
37 }
38 case failureType:
39 return {
40 ...state,
41 isFetching: false
42 }
43 default:
44 return state
45 }
46 }
47
48 return (state = {}, action) => {
49 // Update pagination by key

Callers 1

paginateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected