Redux Devtool(chrome 扩展)不显示状态 [英] Redux Devtool (chrome extension) not displaying state
本文介绍了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 中状态一直为空.(不在应用中)
这是我创建商店的地方:
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'));
这是操作:
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屋!
查看全文