You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even though I'm a big fan of dependency injection, doing it properly in a react with redux app has been challenging.
One of the things being currently handled by the dependency injection container are redux state and actions, which is done by converting components in services and decorating them with connect.
One way to avoid having to define full chains of components as injectable services would be moving to use redux hooks instead.
Try to migrate one reducer so that it exposes custom selector hooks and action hooks, and see how it feels.
Considerations:
Is testing going to become harder? With DI, it was easier to explicitly pass dependencies. With hooks, every component test will have to define a redux provider and create a store.
Should we define one hook per reducer module exposing its state? Another for all actions? One hook per action?
The text was updated successfully, but these errors were encountered:
Even though I'm a big fan of dependency injection, doing it properly in a react with redux app has been challenging.
One of the things being currently handled by the dependency injection container are redux state and actions, which is done by converting components in services and decorating them with
connect
.One way to avoid having to define full chains of components as injectable services would be moving to use redux hooks instead.
Try to migrate one reducer so that it exposes custom selector hooks and action hooks, and see how it feels.
Considerations:
The text was updated successfully, but these errors were encountered: