Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redux Devtool (chrome extension) not displaying state

I am new with Redux and newer with Redux devtool.

I made a simple app in which you click on a user and it display some data about him.

So basically in the state I have the current selected user.

But I don't know why the state keep beeing empty in redux devtool. (not in the app)

Here is where I create my store :

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';

import App from './components/app';
import reducers from './reducers';

const createStoreWithMiddleware = applyMiddleware()(createStore);

ReactDOM.render(
  <Provider store={createStoreWithMiddleware(reducers)}>
    <App />
  </Provider>
  , document.querySelector('.container'));

And here is the action :

export const USER_SELECTED = 'USER_SELECTED'
export function selectUser(user){
    return {
        type : USER_SELECTED,
        payload : user
    }

}

Here is a reducer :

import {USER_SELECTED} from '../actions/index'
export default function (state = null,action){
    switch(action.type){
        case USER_SELECTED :
            return action.payload
    }

    return state

}

And finally a call to the action :

this.props.selectUser(user)

The app works very well but I am probably missing something.

Thanks for your help !

like image 692
Topsy Avatar asked May 10 '17 01:05

Topsy


People also ask

How do I see Redux state in Chrome?

From the navigation bar within the Chrome developer tools, you can find the Redux DevTools by selecting the new Redux panel, made available by the Redux DevTools Chrome extension (figure 3.5).

Why Redux is not showing in Chrome?

The fix: Head over to Redux DevTools from the Chrome instance running the debug localhost server, and hit Remove from Chrome then Install. And you should have Redux DevTools in your Chrome inspect.

How do I enable Redux DevTools trace?

By default it's disabled as, depending of the use case, generating and serializing stack traces for every action can impact the performance. To enable it, set trace option to true as in examples.


1 Answers

Did you add this line to your store?

window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()

github.com/zalmoxisus/redux-devtools-extension#11-basic-stor‌​e

like image 65
Charlie L Avatar answered Sep 21 '22 13:09

Charlie L