redux-injectors | Asynchronous injectors for Redux reducers | State Container library
kandi X-RAY | redux-injectors Summary
kandi X-RAY | redux-injectors Summary
Dynamically load redux reducers and redux-saga sagas as needed, instead of loading them all upfront. This has some nice benefits, such as avoiding having to manage a big global list of reducers and sagas. It also allows more effective use of code-splitting. See motivation. As used by react-boilerplate.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Inject saga .
- Represents the application .
- Ejects saga factory .
- Enhance reducers .
- Injector inject reducer .
- Creates a new Manager .
- Create a new instance of saga .
- reducer reducer for loading results
- Creates a reducer for the injector .
- Fetches results for a search
redux-injectors Key Features
redux-injectors Examples and Code Snippets
Community Discussions
Trending Discussions on redux-injectors
QUESTION
rtk-query is my daily use lib thanks for the great work. I inject reducer with redux-injectors but can`t use caching and other features of rtk-query. Does it have any lib injecting middleware dynamically?
...ANSWER
Answered 2021-May-29 at 20:00Redux middleware are normally only added once, as the store is created. This is because the applyMiddleware()
enhancer has to be defined as part of the store creation process.
I have seen a few attempts to create a middleware that would let you dynamically modify the original middleware setup. I haven't tried any of them, but you may be able to look at these and either use them as-is or as a source of inspiration:
QUESTION
I have the same problem as addressed in the following question. but with a different library. How to reset the state of a Redux store?
I am using redux-injectors from react-boilerplate and am using the enhancers provided from the library. I need to clear all the redux state on logout, but since my logout is on a separate global slice it can only affect the global slice and not other redux states. How do I clear all other states calling an action from global state?
Here's how I combine reducers:
...ANSWER
Answered 2021-May-27 at 12:46One solution could be to -
- Define an "injected saga" for each of the "injected-reducer" which is side-effected by the "logout" action.
- In so defined "injected-saga", define clean-up actions particular to that injected reducer, while observing for the "logout" action.
- So, in theory, when "logout" action is dispatched all the injected saga defined like above will run the clean-up actions resulting in logout equivalent slice in individual reducers.
Try this and this should sort that out.
:: Updated ::
A little difference to avoid creating saga for all the other relevant component/slices.
Working prototype - https://stackblitz.com/edit/inject-reducer?devtoolsheight=33&file=src/App.js
QUESTION
I have problem configuring connect-react-router. I keep getting Error: Could not find router reducer in state tree, it must be mounted under "router"
.
I'm using react, redux-toolkit, typescript and using this react template as base. I have seen all the questions and answers related to this error and tried, but nothing worked. I'm using history
with version 4.10.1
Here is my code, can someone help me to point out where is the issue?
reducers.ts
...ANSWER
Answered 2021-Apr-18 at 01:28This is honestly a very strange setup that you have here. You initially create the store with no reducers and inject them all after the fact.
Your createReducer()
function is called by configureAppStore()
without any arguments. When this happens, you are returning a reducer which does not have the required router
property. Why? Your app will always get initialized without a router
reducer.
QUESTION
I am trying to install node_modules
for my project, but instead of loading the libraries in package.json
, npm install the latest ones. Before I used the command npm to install -g npm@latest
, did it have any effect?
I tried npm install --force
, npm install --legacy-peer-deps
, and remove node but it has same error
My package.
ANSWER
Answered 2021-Apr-07 at 03:18The caret ^
means it can install the most recent compatible version. If you want it to install a specific version, you can remove the ^
in front of the versions.
See package.json docs and semver
The caret will let it install a later version that doesn't change the first number. For instance your package.json specifies ^4.0.0
for @ant-design/icons
, but it installed 4.6.2
. Since the 4
didn't change, that is acceptable.
QUESTION
I am trying to add the library redux-injectors from react-boilerplate in my project. However, I get the issue in the image below. My file configureStore is presented below, you can also find it in this repository: https://github.com/guifeliper/example-redux-injectors
What I can do to have the redux-injectors working, I always get this error when I try to apply the library, it seems that my middleware is not in the correct format. Do you have any clue about it?
...ANSWER
Answered 2020-May-17 at 15:56The final solution was the following:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install redux-injectors
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page