简体   繁体   English

反应开发工具未在 Chrome 浏览器中加载

[英]react dev tools not loading in Chrome browser

I'm debugging an application which uses React.js, the Chrome Extensions list clearly shows that the React Developer Tools are installed, and when i access the React site at http://facebook.github.io/react/ i can clearly see a "React" tab in the developer tools window.我正在调试一个使用 React.js 的应用程序,Chrome 扩展列表清楚地显示已安装 React 开发人员工具,当我访问http://facebook.github.io/react/的 React 站点时,我可以清楚地看到开发人员工具窗口中的“React”选项卡。 Yet when i'm debugging my application i see this in the console:然而,当我调试我的应用程序时,我在控制台中看到了这个:

Download the React DevTools for a better development experience: http://fb.me/react-devtools React.js:87

Can someone tell me how to get it to use the React Developer Tools?有人能告诉我如何让它使用 React 开发者工具吗?

thanks!谢谢!

如果您在浏览器中打开了本地 html 文件 (file://...),那么您必须首先打开 chrome 扩展并选中“允许访问文件 URL”。

You no longer need to do anything.你不再需要做任何事情。


For older react versions, the main requirement is that window.React is set.对于较旧的 react 版本,主要要求是设置了 window.React。 If you're using a module system:如果您使用的是模块系统:

if (typeof window !== 'undefined') {
    window.React = React;
}

This should usually be done in your main source file.这通常应该在您的主源文件中完成。

That message always displays, even if the React dev tools are installed and working on the current page.即使 React 开发工具已安装并在当前页面上运行,该消息也会始终显示。 This will be fixed in 0.12 (and is already fixed in master).这将在 0.12 中修复(并且已经在 master 中修复)。 See https://github.com/facebook/react/pull/953 .请参阅https://github.com/facebook/react/pull/953

React tools also won't work if you're in incognito mode.如果您处于隐身模式,React 工具也将无法工作。 Might help someone.可能会帮助某人。

If you run react app locally you have to如果你在本地运行 react app 你必须

  1. Install "react-devtools" (bcz chrome will not deduct it is a React App when you run in local)安装“react-devtools”(在本地运行时,bcz chrome不会推断它是一个React App)

    npm install -g react-devtools

  2. And add "React Developer Tools" extension to chrome并将“React Developer Tools”扩展添加到 chrome

If you are using Webpack, make sure that your webpack.config.js file doesn't prevent the Plugin from initializing.如果您使用的是 Webpack,请确保您的 webpack.config.js 文件不会阻止插件初始化。 My webpack script had this line:我的 webpack 脚本有这一行:

  plugins: [
    new webpack.DefinePlugin({
        '__REACT_DEVTOOLS_GLOBAL_HOOK__': '({ isDisabled: true })'
    }),
  ],

I deleted it and my React Dev Tools works again.我删除了它,我的 React 开发工具又可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM