redux-devtools-extension icon indicating copy to clipboard operation
redux-devtools-extension copied to clipboard

Multiple instances in dropdown

Open tgreen7 opened this issue 7 years ago • 25 comments

I setup the extension as specified in the docs

import { applyMiddleware, compose, createStore } from "redux";
import thunk from "redux-thunk";
import rootReducer from "./reducers";

const composeEnhancers =
  typeof window === "object" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
    ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
        // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
      })
    : compose;

const enhancer = composeEnhancers(applyMiddleware(thunk));
const store = createStore(rootReducer, enhancer);

export default store;

But there are always multiple instances listed in the dropdown: screen shot 2018-01-17 at 10 35 55 pm

Also autoselect instance does not seem to work. Why are there multiple instances listed? It would be great to be able to open the devtools and immediately see the useful actions.

Thanks!

tgreen7 avatar Jan 18 '18 06:01 tgreen7

Bumping this as I have also run into this issue on multiple projects. Thanks!

tnrich avatar Jan 22 '18 23:01 tnrich

image

@zalmoxisus any idea what might be causing the above issue?

tnrich avatar Feb 01 '18 23:02 tnrich

Hi. Related but somewhat different. I have a situation where I am rendering a separate store per each component I render. It correctly displays all the instances in the dropdown and adds more when I add more. However, when any of the components are unmounted the instances remain active in this menu. I feel as though this is not correct behaviour and may be contributing to the issues mentioned here

tompuric avatar Feb 21 '18 10:02 tompuric

Same issue here.

kallebornemark avatar Mar 20 '18 09:03 kallebornemark

same issue here as well

mcianc avatar Apr 05 '18 08:04 mcianc

Sam here

ross2411 avatar Apr 20 '18 13:04 ross2411

same here

ninett2 avatar Aug 17 '18 07:08 ninett2

Hi Any updates on this issue?

aman-jain avatar Aug 19 '18 05:08 aman-jain

I'm also facing this problem here.

"@ngrx/store": "5.2.0",
  "@ngrx/store-devtools": "5.2.0",

rogsfernandes avatar Nov 16 '18 13:11 rogsfernandes

@rogeriosantos92 that's from @ngrx/store-devtools part, it's not destroying previous instance and creating a new one, the extension shows what it receives from there. Unfortunately, I'm not using ngrx and would be great if someone else can look into that. Also refer to #314.

Regarding the reports for Redux, it would be useful if someone can provide an example to reproduce the issue. I saw something similar with webpack hot reloading the app.

zalmoxisus avatar Nov 16 '18 16:11 zalmoxisus

I noticed this happening with a react-hot-loader setup. Each time I update a component it will create a new instance. My setup might be wrong tho.

vhpoet avatar Dec 13 '18 00:12 vhpoet

@vhpoet it is related to webpack hot reloader, as it was running the script in a new iframe on every hot-reloading, I fixed that with adding a delay, but that was some years ago and something might been changed. If you can share an example repo I'd look into it.

zalmoxisus avatar Dec 13 '18 01:12 zalmoxisus

@zalmoxisus I was mistakenly replacing the store on every hot load by calling https://redux.js.org/api/store#replaceReducer, but I think it should just replace the store in the devtools instead of creating a new one.

vhpoet avatar Dec 13 '18 01:12 vhpoet

@vhpoet you can do that and it shouldn't cause issues, we're doing that in our examples.

zalmoxisus avatar Dec 13 '18 12:12 zalmoxisus

I got same problem with vanilla CRA app (v2) not with hot reloading but the default auto refreshing behavior

json2d avatar Sep 09 '19 02:09 json2d

It would be great if we could set in settings to only display instances of the current window or tab. Otherwise, it's difficult to know which is the instance of the current tab if you set a name in options and open a multiple tabs of the same page.

So regarding the current issue. This somehow seems to solve the issue:

const devtools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__
const enhancer = devtools && devtools({ name: 'Whatever', instanceId: 1 })
...
const AppExample = () => {
   React.useEffect(() => () => devtools && devtools.connect({ instanceId: 1 }).unsubscribe()), [])
   ....
}

This is a React (speudo-code) example. The idea was to disallow action from dev tools once the app is no longer mounted. This kind of works, dispatching is prevented. However, it doesn't disappear from the instances list. Although, I doubt this is the best approach.

I ended up doing:

devtools && devtools.disconnect()

This works ... as long as there is only one listener. However, other stores are also unsubscribed when doing this which is undesirable.

eddyw avatar Oct 29 '19 17:10 eddyw

So what are those instances and what do they exactly mean?

I have 2 items with the same name in that drop-down in a basic app. The first one lists my actions, while the second one is empty. Here is a screencast of the issue: https://www.screencast.com/t/7UoAbeAPh

I underline that I don't create many stores, I'm using just one:

From my index.js:

import { createStore, applyMiddleware, compose  } from "redux";
import createSagaMiddleware from "redux-saga";

import rootReducer from "./store/reducers";
import rootSaga from "./store/sagas";

// noinspection JSUnresolvedVariable
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const sagaMiddleware = createSagaMiddleware();
const store = createStore(
  rootReducer,
  composeEnhancers(applyMiddleware(logger, sagaMiddleware))
);
sagaMiddleware.run(rootSaga);

What I do wrong?

OnkelTem avatar Dec 11 '19 15:12 OnkelTem

Houstan we have a problem, having same issue :(

saadbinsaeed avatar Apr 25 '20 19:04 saadbinsaeed

Same here

Milkhan avatar Nov 25 '20 16:11 Milkhan

Same here. Using redux-toolkit with Next js..

jota12x avatar Feb 26 '21 09:02 jota12x

Same problem, using redux-toolkit with CRA

Froglegg avatar Mar 09 '21 15:03 Froglegg

Same here. Using redux-toolkit with Next js..

In my case, the problem was solved by using the next-redux-wrapper library

jota12x avatar Mar 10 '21 03:03 jota12x

I had this issue whilst implementing React Admin in another application. Took me a moment to figure out that the issue was that the boilerplate code I copied over for initialising the store meant a new store was initialised on each render:

const App = () => (
    <Provider
        store={createAdminStore({
            authProvider,
            dataProvider,
            history,
        })}
    >
        <Admin
            authProvider={authProvider}
            dataProvider={dataProvider}
            history={history}
            title="My Admin"
        >
        ...
    </Provider>
);

Solution was to initiate store outside of the component (SO post)

OllyDS avatar Jun 01 '21 17:06 OllyDS

I had the same issue, fixed it by initializing the store in another file outside the _app component. Using NextJs

Kayle54187 avatar Jan 04 '22 16:01 Kayle54187

Just noticed the readme if this repository says:

This repo is no longer the home of the redux-devtools-extension. The new home is https://github.com/reduxjs/redux-devtools. Please file your issues and PRs there.

inouiw avatar Nov 01 '23 08:11 inouiw