Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devToolsExtension does not accept enhancers #365

Closed
inxilpro opened this issue May 26, 2017 · 2 comments
Closed

devToolsExtension does not accept enhancers #365

inxilpro opened this issue May 26, 2017 · 2 comments

Comments

@inxilpro
Copy link

The devToolsExtension enhancer in pageScript.js take three arguments: reducer, preloadedState, and config. This means that if you have an enhancer chain like:

const compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
const enhancer = compose(
    applyMiddleware(...middleware),
    middlewareThatUsesEnhancers()
);

The enhancers passed by middlewareThatUsesEnhancers to createStore will never get fired. This is the cause of issues like redux-offline/redux-offline#66 — any enhancer that internally calls additional enhancers will not work with redux devtools as the rightmost enhancer.

I'll try to put together a PR shortly, but in the interim, you can add the following to your enhancer chain:

const compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
const enhancer = compose(
    applyMiddleware(...middleware),
    middlewareThatUsesEnhancers(),
    // Add this to the end of your enhancer chain:
    (createStore) => (reducer, preloadedState, enhancer) => enhancer(createStore)(reducer, preloadedState)
);
@inxilpro
Copy link
Author

It looks like if you pass a configuration object, it does accept reducers, but otherwise it does not.

@zalmoxisus
Copy link
Owner

zalmoxisus commented May 28, 2017

It looks like if you pass a configuration object, it does accept reducers, but otherwise it does not.

Yes, it's intended, see #310 (comment).

However, we better just throw an error in the previous case to avoid the confusion. Not to break those who are using it (as intended initially), we should start with a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants