Skip to content

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

@croraf

Description

@croraf

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions