v2.0.0 #33
BenLorantfy
announced in
Announcements
v2.0.0
#33
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It’s been a long time coming, but redux-injectors 2.0 is here 🎉
This release contains some breaking changes and some new features. Unfortunately some breaking changes were needed in order to fix #19 .
For the announcement blog post, see this link.
💥 Breaking Changes
useInjectReducer
useLayoutEffect
instead of during the render. This means the following patterns will be broken:useSelector
call after a call touseInjectReducer
will result inundefined
for the first render, if the selector tries to select from a piece of state that the reducer manages. If you need to do this, please make your selector resilient to undefined state.useLayoutEffect
inside a component further down the tree. This can be fixed by any of the following:useEffect
instead ofuseLayoutEffect
useInjectReducer
now returns a boolean indicating whether or not the reducer has finished injecting. This allows you to returnnull
if the boolean isfalse
instead of the component's children.createManager
API which does the above point for youuseInjectSaga
useLayoutEffect
instead of during the render. This means the saga will not catch a dispatch made inside auseLayoutEffect
inside a component further down the tree. This can be fixed in the same ways as explained in theuseInjectReducer
sectionCOUNTER
. In this mode, the saga will be injected once at-least 1 component mounts that depends on this saga. The saga will be ejected once every component that depends on this saga un-mounts. This means multiple components can inject the saga, but the saga will only run once until every one of these components un-mounts.useInjectSaga
was removed. The default and only possible mode for saga injection is nowCOUNTER
.🚀 New Features
createManager
This is a new API that creates a "manager" component given a reducer and/or saga. Each manager will only render its children after both
the reducer and saga has been injected. You can almost think of managers like "providers" for reducers and sagas.
This is now the recommended way to use
redux-injectors
because it avoids some caveats withuseInjectReducer
anduseInjectSaga
.COUNTER mode
The
COUNTER
mode is a new saga injection mode, and the only mode used byuseInjectSaga
. This mode is relevant when multipleuseInjectSaga
are injecting the same saga. When the firstuseInjectSaga
injects, the saga will be run. Each subsequentuseInjectSaga
will not re-run the saga. The saga will be ejected when the last component using the saga un-mounts.In other words, this means multiple components can inject the saga, but the saga will only run once until every one of these components un-mounts. Thanks @goranurukalo for the contribution!
📝 Documentation
shouldHotReload: false
for redux dev tools.This discussion was created from the release v2.0.0.
Beta Was this translation helpful? Give feedback.
All reactions