Skip to content

Allow use of __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ #1996

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

Merged
merged 2 commits into from
Jan 28, 2019
Merged

Allow use of __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ #1996

merged 2 commits into from
Jan 28, 2019

Conversation

remcohaszing
Copy link
Contributor

This style guide disallows the use of underscores in properties. However, the Redux browser extension requires the use of a variable named __REDUX_DEVTOOLS_EXTENSION_COMPOSE__. Since Redux is so popular with React, it makes sense to allow this.

This saves an eslint-disable comment in pretty much all of my React projects. I’m probably not the only one.

…ON_COMPOSE__`

This style guide disallows the use of underscores in properties. However, the
Redux browser extension requires the use of a variable named
`__REDUX_DEVTOOLS_EXTENSION_COMPOSE__`. Since Redux is so popular with React,
it makes sense to allow this.
@ljharb
Copy link
Collaborator

ljharb commented Jan 21, 2019

What's the use of this property? It doesn't appear anywhere in the airbnb codebase, and we use redux extensively.

@remcohaszing
Copy link
Contributor Author

It allows to attach the redux devtools extension to the redux store.

Typically, each of my redux code bases contains this piece of code:

import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
import thunk from 'redux-thunk';

import * as reducers from './actions';

const composeEnhancers =
  // eslint-disable-next-line no-underscore-dangle
  (process.env.NODE_ENV !== 'production' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;
const store = createStore(combineReducers(reducers), composeEnhancers(applyMiddleware(thunk)));

Copy link
Collaborator

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, thanks for explaining.

@ljharb
Copy link
Collaborator

ljharb commented Jan 26, 2019

(i'm going to tweak this a bit so it applies when using the main config, and not the base)

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

Successfully merging this pull request may close these issues.

3 participants