5

I use browserify to bundle ReactJS and (among others) react-router. But when I look in the console, the message ...

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

... shows up twice (!) telling me that in fact two ReactJS instances are running.

If I look in my browserified JS I saw the ReactJS source only once.

How would I avoid this?

package.json:

"dependencies": {
    "LiveScript": "^1.3.0",
    "jquery": "*",
    "firebase": "*",
    "react": "0.11.2",
    "reactfire": "*",
    "react-router": "*",
    ...
}

When I run npm ls | grep -i react I get:

___ react@0.11.2
___ react-router@0.9.4
___ reactfire@0.3.0
_ ___ react@0.11.2
4

2 回答 2

1

运行npm dedupe。很可能它只是反应的两个不同的补丁版本。

您永远不应该使用通配符来表示依赖项。对于 reactfire<0.1和 react-router ^0.9

于 2014-10-26T14:27:56.117 回答
1

检查您是否正在使用不同的名称导入反应。例如

var React = require('react');

var React = require('React');

将导致 react 被导入 react 两次。

于 2015-07-13T20:23:44.593 回答