redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

How to connect to redux devtools?

Open RichMatthews opened this issue 4 years ago • 35 comments

I'm seeing a fair bit of conflicting info of how to set it up. I'm working with react native

I've gone with this:

import { configureStore } from '@reduxjs/toolkit'
import devToolsEnhancer from 'remote-redux-devtools'
import leaguesReducer from '../reducer'

const store = configureStore({
    reducer: {
        leagues: leaguesReducer,
    },
    devTools: false,
    enhancers: [devToolsEnhancer({ realtime: true })],
})

export default store

passing my store into provider. if I log store.getState() it works in the console. I cant connect to devtools, what do I need to do?

RichMatthews avatar Nov 27 '20 15:11 RichMatthews

You are doing the right thing.

Unfortunately though, the https certificate of https://remotedev.io has expired last year. And the remote devtools try to connect over https by default (which is a good thing). So you have to either use a local server, or disable encryption by setting the secure option to false, sending all your store contents unencrypted over the internet.

Unfortunately, both are not very nice options.

@markerikson there is an issue over at https://github.com/zalmoxisus/remote-redux-devtools/issues/139, but @zalmoxisus is not answering. Do you have other ways of contacting them? If it's just the certificate, the we can surely help with that (setting up LetsEncrypt is usually a breeze).

phryneas avatar Nov 27 '20 16:11 phryneas

Not really, no. They were already mostly inactive the last couple years.

The main Redux DevTools repo did get transferred to the reduxjs Github org a few months ago, I think, and @timdorr now has publish rights for the browser extensions.

Don't know if anything was done about this tool, though.

markerikson avatar Nov 27 '20 16:11 markerikson

So the only thing we could really do would be to fork remote-redux-devtools and set up our own domain :/

The hosting is something I could probably do on my infrastructure, but right now I have other things on my mind than setting it up. But let's put it on the TODO list in the long run.

phryneas avatar Nov 27 '20 17:11 phryneas

Yes, I do have access to all of that now. There was an effort to get that all updated, but I think it fizzled out a bit.

timdorr avatar Nov 28 '20 03:11 timdorr

Oh good - does that really include the remote-redux-devtools repo / site too?

Lenz, are you saying that it's a site that needs a new cert? I haven't looked at remote-redux-devtools to see how it works.

markerikson avatar Nov 28 '20 03:11 markerikson

Yup, exactly that. That same cert might need some extra configuration to be also delivered over websocket (?) but that's the exact same cert.

Click this link to see: https://remotedev.io/ - as soon as you accept the insecure certificate, the remote devtools start working again as long as the redux that tries to connect from them is running in the same browser that does just allow the insecure connection now. (just that's not really the point of remote-dev-tools -.-)

phryneas avatar Nov 28 '20 07:11 phryneas

so I've managed to successfully connect to React Native Debugger app.

and this worked:

const store = createStore(leaguesReducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())

how would this look as the equivalent in toolkit? where do I put the window. references?

RichMatthews avatar Nov 29 '20 20:11 RichMatthews

RTK's configureStore should do that automatically:

configureStore({reducer: leaguesReducer})

markerikson avatar Nov 29 '20 20:11 markerikson

ah cool, yeh that worked. might be worth updating the docs slightly here as it is simple to setup with React Native as it turns out but it took me a couple of days and a bunch of internet browsing to get there

RichMatthews avatar Nov 29 '20 20:11 RichMatthews

@RichMatthews can you clarify what specific steps need to be done to get this to work with RN?

markerikson avatar Mar 23 '21 02:03 markerikson

@RichMatthews can you clarify what specific steps need to be done to get this to work with RN?

@RichMatthews yes, please chime in. :-)

jkoutavas avatar Apr 26 '21 12:04 jkoutavas

Can anyone make it with React native? I still haven't succeeded

hasanaktas avatar May 07 '21 02:05 hasanaktas

@hasanaktas @markerikson After a few hours this is what worked for me:

const store = configureStore({ reducer:{ general:GeneralReducers }, devTools:[ devToolsEnhancer({ realtime: true }) ], })

I've only been able to get it to work with the React Native Debugger app (https://github.com/jhen0409/react-native-debugger)

The steps that I took where:

  1. run project
  2. open React Native Debugger app at the desired port open 'rndebugger://set-debugger-loc?host=localhost&port=8070' which I made a packadge.json script for convenience
  3. then I started the debug mode on the project

Hope this helps

Pepeu07 avatar Jun 08 '21 07:06 Pepeu07

@Pepeu07 I tried it myself. I could even connect to React Native Debugger without any additional configuration.

export const rootStore = configureStore({
    reducer: rootReducer,
});
       "react-native": "0.62.0",
        "react": "16.11.0",
        "@reduxjs/toolkit": "^1.5.1",
        "react-redux": "^7.2.4"

Sir-hennihau avatar Jun 11 '21 10:06 Sir-hennihau

Can anyone make it with React native? I still haven't succeeded

use react-native-debugger , you open redux devtool without any config

phamquyetthang avatar Aug 11 '21 04:08 phamquyetthang

Here's how I got it working

Installed DevTool cli

yarn add --dev @redux-devtools/cli

add below config as a script

"scripts": { "redux-devtools": "redux-devtools --open=electron --hostname=localhost --port=8000" }

Make changes to store like below (don't forget to add port number same as the script above)

import { configureStore } from '@reduxjs/toolkit'
import authReducer from '../features/auth/authSlice';
import devToolsEnhancer from 'remote-redux-devtools';

export default configureStore({
    reducer: {
        auth:authReducer,
    },
    devTools: false,
    enhancers: [devToolsEnhancer({ realtime: true, port: 8000 })],
})

First, run the localserver

yarn redux-devtools

then the react application if not already serving someplace

yarn start

finally connect

Screenshot 2021-12-08 at 6 09 15 am

solancer avatar Dec 08 '21 00:12 solancer

@solancer do we need to to pass the actioncreators, like in: https://github.com/zalmoxisus/redux-devtools-extension/commit/64717bb9b3534ff616d9db56c2be680627c7b09d ?

export default configureStore({
    reducer: {
        auth:authReducer,
    },
    devTools: false,
    enhancers: [devToolsEnhancer({ actionCreators, trace: true, traceLimit: 25,realtime: true, port: 8000 })],
})

seems like tracing of actions does not work. Also it seems like a hassle to pass the actionCreators manually. (I need to use the remote devtools, because I work on a browser extension)

spirobel avatar Dec 08 '21 21:12 spirobel

How to do in typescript?

umarabdullah23 avatar Feb 04 '22 10:02 umarabdullah23

@umarCogentlabs with exactly the same code.

phryneas avatar Feb 04 '22 10:02 phryneas

just do devTools: true , its working for me

const store = configureStore({
  reducer: {
    // Add the generated reducer as a specific top-level slice
  },
  devTools: true,
});

dipanjanpanja6 avatar Apr 22 '22 10:04 dipanjanpanja6

Screenshot 2022-04-27 at 12 17 05 I have setup this but still not working, doesn't show anything in extension

Edit : It worked after cleaning and restarting

Bsingh2697 avatar Apr 27 '22 11:04 Bsingh2697

@Bsingh2697 you should not even need devTools: true. Are you in the same browser here?

phryneas avatar Apr 27 '22 16:04 phryneas

@Bsingh2697 remove enhancers and middleware and try once.

dipanjanpanja6 avatar Apr 27 '22 17:04 dipanjanpanja6

just do devTools: true , its working for me

@dipanjanpanja6 what if you need to use remote devtools like me? (I am developing a browser extension, so the normal redux devtools dont work)

spirobel avatar May 04 '22 04:05 spirobel

hey guys I wonder if anyone knows how to make DevTools work with https dev server?

B-R-Bender avatar May 17 '22 17:05 B-R-Bender

@B-R-Bender the devtools are in your browser, so is the website - there is no data sent over any wire, so it doesn't matter if you use http or https

phryneas avatar May 17 '22 17:05 phryneas

@phryneas the thing is I'm using nx as a monorepo handler and one I've update my config to use ssl I'm not able to see anything in redux devtools I've tried to turn ssl off and devtools are back

B-R-Bender avatar May 18 '22 10:05 B-R-Bender

@B-R-Bender you are looking at a website that is using Redux and you have opened the Redux Devtools in the same browser tab, right?

phryneas avatar May 18 '22 12:05 phryneas

@phryneas sure but looks like it was a glitch (not sure where exactly) as today, after I've switched to https again, it works just fine

B-R-Bender avatar May 19 '22 10:05 B-R-Bender

has anyone manage to make the debugger work with windows machine?

mirek11s avatar Jul 07 '22 11:07 mirek11s