D
D
Dolerum2019-10-29 17:31:17
React
Dolerum, 2019-10-29 17:31:17

How to make a page transition in a reducer?

Hello.
There was a problem.
You need to make a page transition in one reducer for different sank requests to the server. Transitions are carried out by clicking on the button (in the container).
The fact is that if you set one page: 1 / currentPage: 1 in the state and do state.page + 1 on different cases, then I come to the conclusion that when I make one request on the server and scroll through the incoming data page by page and then do another request - then these pages that were in the previous request are also valid in the current one, because it is clear that the state is the same and the object is the same for all this.
In this connection, the question is, how competently can you make such a stray? No shit code. If possible, with code examples.
Maybe split the big reducer into separate reducers? Then the question is, how do I correctly and elegantly map almost the same data from different reducers? Is it possible to merge them somehow?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Konovalenko, 2019-10-29
@konovalenko_v

import { combineReducers } from "redux";

import userReducer from "./user-reducer";
import ordersTableReducer from "./orders/table-reducer";
import ordersModalsReducer from "./orders/modals-reducer";

export default combineReducers({

  // Common
  user: userReducer,

  // Orders
  orders: combineReducers({
    table: ordersTableReducer,
    modals: ordersModalsReducer,
  }),

  // ..... 
});

"combineReducers" to split a large reducer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question