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
Uh oh!
There was an error while loading. Please reload this page.
-
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
useInjectReduceruseLayoutEffectinstead of during the render. This means the following patterns will be broken:useSelectorcall after a call touseInjectReducerwill result inundefinedfor 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.useLayoutEffectinside a component further down the tree. This can be fixed by any of the following:useEffectinstead ofuseLayoutEffectuseInjectReducernow returns a boolean indicating whether or not the reducer has finished injecting. This allows you to returnnullif the boolean isfalseinstead of the component's children.createManagerAPI which does the above point for youuseInjectSagauseLayoutEffectinstead of during the render. This means the saga will not catch a dispatch made inside auseLayoutEffectinside a component further down the tree. This can be fixed in the same ways as explained in theuseInjectReducersectionCOUNTER. 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.useInjectSagawas removed. The default and only possible mode for saga injection is nowCOUNTER.🚀 New Features
createManagerThis 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-injectorsbecause it avoids some caveats withuseInjectReduceranduseInjectSaga.COUNTER modeThe
COUNTERmode is a new saga injection mode, and the only mode used byuseInjectSaga. This mode is relevant when multipleuseInjectSagaare injecting the same saga. When the firstuseInjectSagainjects, the saga will be run. Each subsequentuseInjectSagawill 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: falsefor redux dev tools.This discussion was created from the release v2.0.0.
Beta Was this translation helpful? Give feedback.
All reactions