Redux Devtool(Chrome扩展程序)未显示状态 [英] Redux Devtool (chrome extension) not displaying state

查看:132
本文介绍了Redux Devtool(Chrome扩展程序)未显示状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Redux的新手,是Redux devtool的新手.

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.

但是我不知道为什么在redux devtool中状态总是空虚.(不在应用程序中)

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

在这里创建我的商店:

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'));

这是动作:

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

}

这是一个减速器:

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

    return state

}

最后调用该动作:

this.props.selectUser(user)

该应用程序运行良好,但我可能丢失了一些东西.

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

感谢您的帮助!

推荐答案

您是否将此行添加到了商店?

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

这篇关于Redux Devtool(Chrome扩展程序)未显示状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆