Giter Site home page Giter Site logo

Comments (16)

abettadapur avatar abettadapur commented on May 17, 2024 3

@geminiyellow Published v2.0.0, which contains this new fix

from redux-dynamic-modules.

navneet-g avatar navneet-g commented on May 17, 2024 1

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.

geminiyellow avatar geminiyellow commented on May 17, 2024

woo, thank you @navneet-g . ok , two ; ) .

from redux-dynamic-modules.

navneet-g avatar navneet-g commented on May 17, 2024

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.

https://github.com/Microsoft/redux-dynamic-modules/blob/users/navneetg/moduleenhancer/packages/redux-dynamic-modules/src/ModuleEnhancer.ts

from redux-dynamic-modules.

navneet-g avatar navneet-g commented on May 17, 2024

@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.

geminiyellow avatar geminiyellow commented on May 17, 2024

woo, thank you @navneet-g

from redux-dynamic-modules.

navneet-g avatar navneet-g commented on May 17, 2024

@geminiyellow did you get a chance to use v2.0.0? Please let us know if you have any feedback.

from redux-dynamic-modules.

geminiyellow avatar geminiyellow commented on May 17, 2024

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.

navneet-g avatar navneet-g commented on May 17, 2024

@geminiyellow I just published a new version (2.0.1)

  1. Pull the new version
  2. import module enhancer import { moduleEnhancer } from "redux-dynamic-modules";
  3. use createStore from redux, and the composed enhancers
createStore(rootRecuer, initialState, compose(moduleEnhancer(), applyMiddleware(...))); 

from redux-dynamic-modules.

geminiyellow avatar geminiyellow commented on May 17, 2024

@navneet-g good, thank you. let me try it.

from redux-dynamic-modules.

navneet-g avatar navneet-g commented on May 17, 2024

@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.

geminiyellow avatar geminiyellow commented on May 17, 2024

@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.

navneet-g avatar navneet-g commented on May 17, 2024

@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.

 avatar commented on May 17, 2024

@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.

 avatar commented on May 17, 2024

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.

geminiyellow avatar geminiyellow commented on May 17, 2024

@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

error

from redux-dynamic-modules.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.