Skip to content

Conversation

@evilj0e
Copy link
Contributor

@evilj0e evilj0e commented Nov 2, 2016

In our project we found some case that can brake your application.
It can be broken when you've tried to pass not a function in enhance array to compose function.

const toEnhance = [
    router.enhancer,
    applyMiddleware(...middleware),
    window && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() // false in this case will cause a bug
];
const enhancer = compose(...toEnhance);

Of course I can filter array before passing it to enhancer, but I think it will be useful to manage it in compose function.

@chevsky
Copy link

chevsky commented Nov 2, 2016

You still can avoid this "bug" in one line if you want.

((window || {}).__REDUX_DEVTOOLS_EXTENSION__ || (() => store => store))()

@markerikson
Copy link
Contributor

I could see some value in this. I know that @jimbolla added a somewhat similar check to React-Redux's connect in v5. Maybe gate the check behind a NODE_ENV check so it only happens in dev?

/cc @timdorr

@timdorr
Copy link
Member

timdorr commented Nov 2, 2016

This is basically what I was thinking here. LGTM. Thanks!

@timdorr timdorr merged commit 89b0c25 into reduxjs:master Nov 2, 2016
seantcoyote pushed a commit to seantcoyote/redux that referenced this pull request Jan 14, 2018
* Add support to compose only functions in utils/compose

* Remove some parens
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

Successfully merging this pull request may close these issues.

4 participants