“No store found” when using Redux chrome extension

后端 未结 7 1077
轮回少年
轮回少年 2021-01-11 11:57

I have a problem with redux chrome extension.

I have the following code in my configureStore.js file :

import {createStore, applyMiddleware} from \'         


        
相关标签:
7条回答
  • 2021-01-11 12:18

    I am late but may help someone, my solution was to use connect the component

    import {connect} from 'react-redux'
    ...
    class MyComponent extends Cmponent{
    ...
    }
    export default connect()(MyComponent)
    
    0 讨论(0)
  • 2021-01-11 12:21

    I write a simple solution in the hope that it will be useful (It is not a definitive solution):

    1. I have to right click on Redux Devtools Extension

    2. Open Remote DevTools

    3. Then change the Settings to use the custom server which is localhost:3000

    And it works

    0 讨论(0)
  • 2021-01-11 12:24

    I've got the solution from here.

    The right code is :

    import {createStore, applyMiddleware, compose} from 'redux';
    import rootReducer from '../reducers/index';
    import thunk from 'redux-thunk';
    
    export default function configureStore(initialState){
      return createStore(
        rootReducer,
        initialState,
        compose(
          applyMiddleware(thunk),
          window.devToolsExtension ? window.devToolsExtension() : f => f
        )
      );
    }
    
    0 讨论(0)
  • 2021-01-11 12:30

    For anyone that none of these worked for, try restarting your server. I had tried for a while and then decided to restart my server. That solved it for me

    0 讨论(0)
  • 2021-01-11 12:34

    There is a simpler solution now from the redux-devtools folks. See:

    section 1.3 Use redux-devtools-extension package from npm at https://github.com/zalmoxisus/redux-devtools-extension

    basically, if you npm install there redux-devtools-extension you can:

    import { createStore, applyMiddleware } from 'redux';
    import { composeWithDevTools } from 'redux-devtools-extension';
    
    const store = createStore(reducer, composeWithDevTools(
      applyMiddleware(...middleware),
      // other store enhancers if any
    ));
    

    In my case I only have one piece of middleware (redux-thunk) but I have an initialState so it looks like this:

    const store = createStore(reducer, initalState, composeWithDevTools(applyMiddleware(thunk)))
    store.subscribe(() => console.log("current store: ", JSON.stringify(store.getState(), null, 4)))
    
    0 讨论(0)
  • 2021-01-11 12:35

    If anyone followed the same (or similar) boilerplate server-side rendering React app setup that I did, you may want to be sure if there are separate server and client files that use createStore(). In my case there were, and I spent a lot of time playing with the server file, when it needed to go into the client file.

    Probably not the best way to do it, but alas, the boilerplate code I used did it that way.

    0 讨论(0)
提交回复
热议问题