Answer the question
In order to leave comments, you need to log in
React + Redax + Sagas - how to build an application correctly?
Talked to an experienced developer about using sagas. If I understood it correctly, then the following division of code in the application results:
- components - basically - the visual part, from the logic - only a small something, maybe a local state for something that is needed only inside the component,
- component container - used to connect and pass part of the state and actions to the props of the component, there may be one for the entire application - then the properties are "descended" into the remaining components, but can also be used for a separate component, if it is inconvenient to "descend" properties from the root component,
- actions - pure functions that are passed to the component and used to call the reducer or saga,
- saga - the main place of the application's business logic (here it is almost all!) + action calls,
- reducers - pure functions that are used to change the readax state.
Did I describe the main points correctly?
If yes, is this the only option, or, in principle, approaches can be different?
Recently, according to instructions from the Internet, I wrote an application, there were no sagas, and I sent most of the logic to actions, incl. asynchronous - using thunk. How good is this practice?
Can you advise something to read exactly on the principles of building relatively large applications in this bundle of tools (React + Redax + Sagas)?
Answer the question
In order to leave comments, you need to log in
Good question, but as for the data model, some patterns in this regard have already been invented for us and they are not bad enough. for example redux-ducks , they can be split as in the example above, or they can be grouped in one . Actually, sagas should be located at the very end, here is my example of organizing a component with sagas
. About the data representation part, I myself constantly try to separate components and containers. But here the main thing is not to overdo it when data is thrown from one parent container through 50 descendants into the component. It’s better then somewhere below to connect to the store and get the desired parameter.
To begin with - the documentation, it also contains the simplest example of using sagas and redux. And on udemy there is a course on the saga - in English and a course on react + redux from Yuri Bur. Dig into the docks for a couple of days and take courses - you'll figure it out
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question