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

when composing enhancers don't crash redux if one enhancer is undefined #3477

Closed
croraf opened this issue Jul 17, 2019 · 2 comments
Closed

Comments

@croraf
Copy link
Contributor

croraf commented Jul 17, 2019

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

For example when "Redux devtools" are not installed in the browser this code:

const enhancers = compose(
    applyMiddleware(thunk), 
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);

const store = createStore(
  reducers,
   /* preloadedState, */
   enhancers,
);

crashes redux with Uncaught TypeError: Cannot read property 'apply' of undefined, because second argument to compose (second enhancer) is undefined.

What is the expected behavior?

Would be good if some enhancer is undefined not to crash, but to continue to operate as if this argument was not provided to compose.
(Not sure if this means the change of compose or the change of createStore)

Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?
Redux version: 4.0.1
OS+Browser: Windows 10 + Chrome 75, Ubuntu 18 + Chrome 75, Windows 10 + IE

@timdorr
Copy link
Member

timdorr commented Jul 17, 2019

We actually specifically removed this way back in #2167. The determination was it is better to fail than to silently continue to execute. We want to know when the store configuration isn't what we expect.

@timdorr timdorr closed this as completed Jul 17, 2019
@croraf
Copy link
Contributor Author

croraf commented Jul 18, 2019

@timdorr OK.

From what I see compose does not fail when undefined is given as an argument. The application should fail at this point saying "an argument is not a function" or something? I think this was the intention of discussion in #2167 ?

Where the application fails is during createStore. And it fails with a non helpful error of "Cannot read property 'apply' of undefined".

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