【问题标题】:react-redux developer tool is inactive on the extension bar and not showing the state of the applicationreact-redux 开发人员工具在扩展栏上处于非活动状态,并且不显示应用程序的状态
【发布时间】:2020-10-21 16:26:30
【问题描述】:

我刚刚完成了 redux-tutorial 并尝试在 redux-devtools 中查看状态。但是 redux-devtools 在扩展栏中处于非活动状态,当我单击它时它会显示菜单 “向右,向左等”。当我选择其中一个选项时,它会以不存在的状态显示数据。这是我的 index.js 文件

import React from 'react';
import {render} from 'react-dom';
import './index.css';
import { createStore } from 'redux'
import App from './components/App';
import rootReducer from './reducers';
import * as serviceWorker from './serviceWorker';
import {Provider} from 'react-redux';

const store = createStore(rootReducer)

render(
    <Provider store={store}>
        <App />
    </Provider>,
    document.getElementById('root')
)
serviceWorker.unregister();

【问题讨论】:

标签: javascript reactjs redux redux-devtools-extension


【解决方案1】:

createStore中添加REDUX_DEVTOOLS_EXTENSION

const store = createStore(
   rootReducer, 
   window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
  );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-04
    • 2018-05-29
    • 2017-10-08
    • 2018-08-13
    • 2015-03-20
    • 2023-03-30
    相关资源
    最近更新 更多