Comments (5)
Further analyzing of dependency patterns in redux feature-based architecture I can come up with:
- dumb components --> static-types
- smart components --> actions & selectors -> static-types
- store --> root reducer --> reducer --> actions -> static-types
- side-effects --> actions & selectors & services -> static-types
- services --> static-types
I would like to create a feature based architecture with the folder structure based on the above constrains, which I think that would promote loose implicit coupling.
from react-redux-typescript-guide.
Hello @piotrwitek, thank you for this guide and typesafe-actions
lib
Have you heard of ducks for redux? I think it will work well for grouping by features, since if you slice store by features, there will be small number of actions for each slice, and they all can go into the same file (types, actions, side-effects, reducer, selectors)
Here is the example: https://gist.github.com/Tauka/15d35f36771d2512200bd9dc9b074807
Not insisting on anything, just a suggestion :) Don't feel obligated to consider it
from react-redux-typescript-guide.
@Tauka Thanks for suggestion, it is really good!
I'll share with you some of my story working with "ducks" and then I'm open for discussion.
"Ducks" look cool and concise but unfortunately they introduce dependency mess which we "front-end developers" tend to forget about when using various bundlers.
If you would use some tool to generate dependency graph of your application (you can see some example I have created here), you would find it much harder to read what is happening on a high level, harder to test (because you have to mock everything), and you'd introduce cyclic dependencies as well which is the worst of them. Basically when you only want to import types or action creators you import all of your feature logic and implicit modules it depend on.
In case of your example look what you implicitly couple your dumb components to (and it will cascade and bring even more stuff from '../../helpers' and '../../redux' modules):
import { createActions, handleActions, combineActions } from "redux-actions";
import { call, put, takeLatest } from "redux-saga/effects";
import { api } from "../../helpers";
import { Root } from "../../redux";
So that's my story why I stopped using and recommending "ducks" in real big apps.
from react-redux-typescript-guide.
@BoostIO funded this issue with $50. Visit this issue on Issuehunt
from react-redux-typescript-guide.
@issuehuntfest has funded $10.00 to this issue. See it on IssueHunt
from react-redux-typescript-guide.
Related Issues (20)
- VSCode Intellisense broken by RootState HOT 1
- Experiencing a type compilation error when using react-redux connect function for a component that does not inject additional properties into the wrapped base component HOT 11
- Suggestion: Examples for new redux hooks and react-router hooks HOT 2
- Playground fails to compile - import order HOT 1
- Regarding 'Typing connected component with redux-thunk integration' section HOT 1
- Q: how to avoid exposing actionCreators when using redux-thunk
- `bindActionCreators` example is outdated
- src/hoc/connected-with-count.tsx type cast is incorrect
- MapDispatchToProps shorthand HOT 5
- Add new example for non-HOC component that uses connect HOT 2
- Cannot run up
- why the WithConnectedCountUsage component cannot increment the counter?
- 'fc-counter-connected-bind-action-creators.usage' component cannot work HOT 2
- property does not exist on type 'IntrinsicAttributes & Pick<any, symbol>'
- Start playground dir has a error
- Why not use immutable
- Slow typescript compile time HOT 1
- I got parsing error
- Link to missing anchor in the guide HOT 2
- Refactor RenderProps components
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-redux-typescript-guide.