Answer the question
In order to leave comments, you need to log in
How to organize interaction with the server API?
I am developing a project in which there is a server part working on the API and a client part on React + Redux.
I try not to connect them with anything so that in the future they do not depend on each other.
Since I am not familiar with React, the question is:
How do I organize routing in React? Do one entry point, and then routing, or do each "resource" its own entry point?
How to properly organize API + React?
PS the project is planned to be large (if it matters), some of the pages will also need to be rendered on the server (for seo)
Answer the question
In order to leave comments, you need to log in
I can use this link to offer, as an example, my project, which has not yet been finalized, but in which you can quite easily see the architecture of the application.
It is worth noting that I use the same architecture on a large commercial project with API / React / Redux, that is, it completely matches your description.
Briefly about the application:
The connection of the application with the API, again, in short:
There are smart and dumb components. Smart components call the necessary actionCreators from the redux/modules folder. ActionCreators access the corresponding module in the api folder, where the server is accessed, from where the data is returned in Promises again to the actionCreator, where the action is dispatched with the data, after which the reducer updates the data in the store. The smart component is updated and updates all of its dumb components that are included in it, passing the received data to them.
Using the written, go through the code and I hope everything will become clear. Good luck.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question