I
I
Icic Bender2018-04-17 21:13:16
React
Icic Bender, 2018-04-17 21:13:16

How to get data from the server and update the page component when the URL changes?

Hello!
The application site uses:

react 16.3, react-dom 16.3, react-redux 5, react-router 4.2, react-router-dom 4.2, react-router-redux 5.0.0-alpha.9, redux 3.7, redux-thunk 2.2

The question considers only the address of the form
/section/:id

Interested in how the following scenario is usually implemented:
  1. The page is open (let's say it's /section/1);
  2. There is a transition to the /section/2 page (the Link component is used);
  3. During the transition, the LOCATION_CHANGE action of the router is triggered;
  4. Somehow (?) a request for data from the server is initiated (the cache option is not considered in this example) ;
  5. The data is received, which, if I'm not mistaken, should call another action;
  6. The page component is updated with the new data.

I rummaged through a lot of guides, official and not very, but all the documentation is very motley and describes the different versions of the libraries used, which complicates understanding. I did not think that such an elementary task could cause problems with understanding the principle of its implementation.
PS
I assume that the standard methods of the life cycle of the React component should not participate here, since Redux is used?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question