Ducks Pattern
Guilherme Lisb?a
Senior Data Engineer | Google Cloud Certified | Python | GCP | Bigquery | Dataflow
The Ducks Pattern is a way to organize the Redux structure and the Redux is a library of state control based on Flux architecture commonly used in the React ecosystem.
Redux even being a good way to control the React states there is a problem with the folder structs that are used, the way the files and folders are structured is a little problem.
Organization commonly used
In the common organization is based on the module, there a problem because
is a little hard to find some things, there is everything together is a bit confused and it'll be getting hard and hard when the application coming to grow the organization will start to be a little less organized. There will be a lot of name repetition and the folder has a lot of imports and exports.
Module organization
The other way is the following one that I particularly like more than the other
but there is still has a problem because to make on little think we have to create 3 files and some of them isn't that long, use it is separate thinks that is about the same contexts and it doesn't make sense. As an example, we can use auth. there is the type that is used to shot the action and the reducer they are 3 pieces of the same thing, separate them is like we have a car and we separate the car's hood, dashboard, and engine. Doesn't look right.
Ducks Pattern
Now we put together the reducers, types and actions and only one file and how to worry about because normally the file wont' get longer.
As you can see in only one file we can put all that you need,