Comments (16)
@geminiyellow Published v2.0.0, which contains this new fix
from redux-dynamic-modules.
Thanks for the question @geminiyellow , it is a really good one. We will push an update to allow this scenario, please give us a day or two.
from redux-dynamic-modules.
woo, thank you @navneet-g . ok , two ; ) .
from redux-dynamic-modules.
Just a quick update, I have started a small refacotr/redesign to better support it, the changes are in following branch, I need to test them out and write some test harness. I hope to get some time over the weekend to finish it off, but no promise :)
Please check it out if you are interested.
from redux-dynamic-modules.
@geminiyellow I have a PR out to support enhancers. Thanks for requesting this feature it helped me improve the design.
#25
To see how you can use it see the unit test where I am using moduleEnhancer with applyMiddleware enhancer
https://github.com/Microsoft/redux-dynamic-modules/pull/25/files#diff-c5cc69a8f5bebda3075b38d7f75aa7ed
from redux-dynamic-modules.
woo, thank you @navneet-g
from redux-dynamic-modules.
@geminiyellow did you get a chance to use v2.0.0? Please let us know if you have any feedback.
from redux-dynamic-modules.
hi @abettadapur , @navneet-g , sorry i have no time to test it yesterday.
i read the PR code, knew that moduleEnhancer
is a enhancer method,
but looks like that i cannot use it directly, and what i can use is the createStore
.
hmm, the configureStore
is changed to createStore
,
name is same as the redux#createStore
but interface is changed,
and it cannot use withredux#compose
,
i dont think that can help i understand how to use it.
when i got the name, i will try to use it as the origin createStore
, but i cannot, right?
could you give me some code show how to use the moduleEnhancer
? and how to add others enhancers to the moduleStore ?
from redux-dynamic-modules.
@geminiyellow I just published a new version (2.0.1)
- Pull the new version
- import module enhancer
import { moduleEnhancer } from "redux-dynamic-modules";
- use createStore from redux, and the composed enhancers
createStore(rootRecuer, initialState, compose(moduleEnhancer(), applyMiddleware(...)));
from redux-dynamic-modules.
@navneet-g good, thank you. let me try it.
from redux-dynamic-modules.
@geminiyellow I have also updated widgets example which now uses moduleEnhancer
https://github.com/Microsoft/redux-dynamic-modules/blob/master/packages/widgets-example/src/App.js
from redux-dynamic-modules.
@navneet-g yes, i notice that, ok, here is my code
const dynamicModuleEnhancer = moduleEnhancer();
const enhancers = [firebaseEnhancer, middlewareEnhancer, offlineEnhancer, dynamicModuleEnhancer];
const createEnhanceStore = compose(...enhancers)(createStore);
export const createReduxStore = initialState => createEnhanceStore(makeRootReducer(), initialState);
and i copy some code from hacker-news
modules
import React from 'react';
import { Text, View } from 'react-native';
import { DynamicModuleLoader } from "redux-dynamic-modules";
export const weatherState = state => (state || {});
const getHackerNewsModule = () => ({
id: "weather",
reducerMap: { weatherState },
});
const EntranceScreen = () => (
<DynamicModuleLoader modules={[getHackerNewsModule()]}>
<View><Text>123</Text></View>
</DynamicModuleLoader>
);
export default EntranceScreen;
and put it in react-navigation
.
but when i start up it
Unexpected keys "offline", "HOME", "FIREBASE", "FIRESTORE" found in previous state received by the reducer. Expected to find one of the known reducer keys instead: "weatherState". Unexpected keys will be ignored.
from redux-dynamic-modules.
@geminiyellow This error means that in the store there are some keys that do not have any associated reducers. Do you know how the reducers for offline, home, firebase and firestore are assigned? may be the enhancers for those middlewares provider the reducers. I suggest you try by changing the order for enhancers
e.g. const enhancers = [dynamicModuleEnhancer, firebaseEnhancer, middlewareEnhancer, offlineEnhancer];
if you can create a minimal repro and provide me a gist to link to a github repo I can debug as well.
from redux-dynamic-modules.
@geminiyellow I was able to repro this and my analysis was correct above.
Please move the dynamicModuleEnhancer as the left most enhancer you use in compose so other enhancers get a chance to register their keys.
e.g. const enhancers = [dynamicModuleEnhancer, firebaseEnhancer, middlewareEnhancer, offlineEnhancer];
from redux-dynamic-modules.
I have also updated the widgets-example to illustrate the same and used offlineEnhancer as an example, please take a look here
https://github.com/Microsoft/redux-dynamic-modules/blob/master/packages/widgets-example/src/App.js
from redux-dynamic-modules.
@navneet-g yes, i had try to change the order before comment.
@navneetg-msft got, but the error still here.
we can recreate it use the latest widgets-example
first , let us copy the code from redux official doc here: https://redux.js.org/api/combinereducers#example
then add something like this:
+ const makeReducers = () => combineReducers({
+ todos,
+ counter
+ })
this.store = createStore(
+ makeReducers(),
- (state, action) => state || {},
and
from redux-dynamic-modules.
Related Issues (20)
- Is it possible to shave off React+ dependencies? HOT 1
- Could it be possible to provide simple Lit Element (Web Components) example
- support for nested reducers HOT 4
- Typing initialActions function
- [Examples] There is no 'enhancements' property
- [Examples] Unused argument 'getState'
- State and reducers are not removed when dynamic component unmounts HOT 2
- PENDING action is gone from sagas HOT 6
- remain module when component unmount HOT 2
- State lost, when moving from one module to another module HOT 1
- Remove module by id HOT 1
- modules are removed before useEffect cleanups are executed
- Update with React 16.x or 17.x
- takexxx saga(saga watched action) in different modules that have been loaded doesn't work in dynamic modules HOT 1
- Build pipeline failing for main
- Library abandoned? HOT 2
- TypeScript React: incorrect children props HOT 3
- This repo is missing important files HOT 3
- Module '"redux-dynamic-modules"' has no exported member 'IModule'.
- Any way to use the redux-toolkit with this lib? I have a code sample in the description..
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 redux-dynamic-modules.