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

Deprecating window.devToolsExtension #220

Closed
zalmoxisus opened this issue Oct 4, 2016 · 14 comments
Closed

Deprecating window.devToolsExtension #220

zalmoxisus opened this issue Oct 4, 2016 · 14 comments

Comments

@zalmoxisus
Copy link
Owner

zalmoxisus commented Oct 4, 2016

window.devToolsExtension is being deprecated in favour of window.__REDUX_DEVTOOLS_EXTENSION__ and window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__. See the README on how to use them and the post about why we added the second function.

Also there's redux-devtools-extension npm package to make things easier.

Now we don’t have the order’s and noop functions’ confusion, also the shared window namespace isn’t too vague anymore. The deprecation warnings will come in the next versions and there will be also more sugar for the npm package.

@vdh
Copy link

vdh commented Oct 6, 2016

I had a really frustrating morning today wondering why window.__REDUX_DEVTOOLS_EXTENSION__ was undefined because of this. It's all well and good to deprecate a feature, but it doesn't help if the documentation (which is linked to directly from 2.6.1.1) is updated well before Chrome eventually gets around to updating the actual extension to 2.7.0 ☹️

@zalmoxisus
Copy link
Owner Author

@vdh, Chrome should update the extension 2 days ago. Maybe you disabled autoupdating extensions somewhere in Chrome settings? Though I didn't know it's possible to disable it.

@vdh
Copy link

vdh commented Oct 6, 2016

Sadly, for some reason Chrome's extension auto-updating isn't so auto, I had to manually force an update.

It might be nice to have an "in 2.7.0" or "as of 2.7.0" note on the deprecated part in the instructions as a hint to check one's plugin version?

zalmoxisus added a commit that referenced this issue Oct 6, 2016
@zalmoxisus
Copy link
Owner Author

zalmoxisus commented Oct 6, 2016

@vdh, I added a note in the README. Anyway, we need autoupdating, as we're moving really fast here and still want to change / improve a lot of things. Hope it was just a temporally problem of Chrome as I didn't experience it before. If the problem with autoupdating will still persist, please open an issue, so we'll add a button to check if the extension is up to date and update it manually.

@oyeanuj
Copy link

oyeanuj commented Nov 8, 2016

@zalmoxisus I was a little confused while upgrading to the latest, around the usage of window.devToolsExtension. My code today looks like this:

const { persistState } = require('redux-devtools');
const DevTools = require('../containers/DevTools/DevTools');
store = createStore(
  reducer,
  initialState,
  compose(
    applyMiddleware(...middleware),
    window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument(),
    persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
  )
);

Now with the new changes that you announced and deprecation of window.devToolsExtension, I changed my code to this:

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
store = createStore(
  reducer,
  initialState,
  composeEnhancers(
    applyMiddleware(...middleware),
    window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : DevTools.instrument(),
    persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
  )
);

but get the following error:

Uncaught Error: DevTools instrumentation should not be applied more than once. Check your store configuration.

I assume this error is because I can't use composeEnhancers with window.__REDUX_DEVTOOLS_EXTENSION. In that case, what is the best way to set it up to still be able to use standard old non-extension devtools & persistState as a backup?

Many thanks on your work on this!

@zalmoxisus
Copy link
Owner Author

zalmoxisus commented Nov 8, 2016

@oyeanuj, yes you shouldn't use both. Best way would be:

let enhancer;
if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
  enhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__(
    applyMiddleware(...middleware)
  );
} else {
  enhancer = compose(
    applyMiddleware(...middleware),
    DevTools.instrument(),
    persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
  );
}
store = createStore(
  reducer,
  initialState,
  enhancer
);

New method, window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__, offers the ability to lock enhancers/middlewares (when the corresponding button is clicked) and to dispatch remote actions through other enhancers. See the blog post for more details. If you don't need those features, you can just replace window.devToolsExtension with window.__REDUX_DEVTOOLS_EXTENSION__.

Also note that the extension already includes persistState.

@oyeanuj
Copy link

oyeanuj commented Nov 8, 2016

@zalmoxisus great, thank you for the detailed answer!

@dfrho
Copy link

dfrho commented Jun 10, 2017

Redux dev tools is an awesome tool - Thanks for the great work on it!

@ghost
Copy link

ghost commented May 1, 2018

For any one who is looking for exactly what to write to make redux dev tools work -
`import { createStore, applyMiddleware, compose } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";

import thunk from "redux-thunk";
import rootReducer from "./reducers";
import { persistState } from "redux-devtools";
import DevTools from "redux-devtools";

const middleware = [thunk];
const initialState = {};
let enhancer;
if (window.REDUX_DEVTOOLS_EXTENSION_COMPOSE) {
enhancer = window.REDUX_DEVTOOLS_EXTENSION_COMPOSE(
applyMiddleware(...middleware)
);
} else {
enhancer = compose(
applyMiddleware(...middleware),
DevTools.instrument(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
);
}

const store = createStore(rootReducer, initialState, enhancer);

export default store;
`

You need to install redux-devtools package with npm i redux-devtools , redux-thunk using npm i redux-thunk in your client directory.

@yairEO
Copy link

yairEO commented Aug 12, 2018

This is how I use it (working fine):

const store = createStore(reducer, initialState, window.devToolsExtension && window.devToolsExtension() );

@bciach
Copy link

bciach commented Sep 13, 2018

@yairEO I am using it the same way, however I am not sure if its correct?

@zalmoxisus
Copy link
Owner Author

I think 2 years is enough for everybody to rename window.devToolsExtension to window.__REDUX_DEVTOOLS_EXTENSION__ in their apps. We'll add a deprecation warning in 2.15.5 and remove the variable in 3.0.

@rlscode
Copy link

rlscode commented Apr 13, 2019

You could try like this

`const middlewares = [thunk];
const composeEnhancers = window.REDUX_DEVTOOLS_EXTENSION_COMPOSE || compose;

export default function configureStore(initialState) {
return createStore(
reducer,
initialState,
composeEnhancers(applyMiddleware(...middlewares))
);
}`

@Methuselah96
Copy link
Collaborator

Removed in 3.0.

@Methuselah96 Methuselah96 unpinned this issue Jan 18, 2022
mans0954 pushed a commit to overleaf/overleaf that referenced this issue Sep 20, 2024
* Add `LaTeX Quality Control` to the readme

* Update dependencies

* Match `web` version
* Update to modern packages
* Update to modern versions

* Import `Link` from `react-router-dom`

* Import Helmet correctly

* Remove `react-router-redux`

It seems that we're not actually getting anything from it (?)

* Update component containers/App

* Revert unecessary changes to containers/App

* Update component containers/Upload

* Revert unnecessary changes to container/Upload

* Fix links

* Add `withNavigation` HOC
* Fix link to `/upload`
* Remove unneeded `navigate` props

* SSR: Use `StaticRouterProvider`

* CSR: Use `createBrowserRouter`

* SSR: Simplify since we don't need to perform queries

* Add `data-testid`s to components

* Update tests (`enzyme` -> `@testing-library`)

* Remove unneeded "before" in tests

* Revert "Remove unneeded "before" in tests"

(actually necessary)

* Rename `devToolsExtension` to `__REDUX_DEVTOOLS_EXTENSION__`

Per zalmoxisus/redux-devtools-extension#220

* Return 404 on invalid paths

* Remove unuseds dependencies

* Re-implement react-router `onUpdate` with `RouteChangedHandler`

It appears that `onUpdate` was removed from react-router
remix-run/react-router#4278

* Update package-lock

* Remove debug log

GitOrigin-RevId: 3244b4266b53ac57a92ed4adc7c0e00b93a6b361
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

8 participants