-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Empty <Top Level></Top Level> in React tab #90
Comments
For me, seems like this happens when the app renders asynchronously and the react panel doesn't update. I can fix by reloading off of the react view and switching on in console. |
@xizhao what do you mean by "reloading off of the react view and switching on in console" How can I possibly reload the react view? |
I mean reloading the page on the "elements" and switching to the "react" tab rather than loading directly with "react". |
@carlosmmelo Does the extension work for you on http://facebook.github.io/react/? That's running React 0.13 right now. @xizhao's issue is something I've also observed. |
@spicyj yes it works on that page. When this issue started to happen on our end is when we updated to |
I'm having the same problem. I'm using |
Excellent, that would confirm that the extension is not compatible with react-router Sent from my iPhone
|
@spicyj do you know any way we could debug this? You were right it appears that it works on some websites with react-router, I'm out of ideas now. |
Not without seeing it since I don't know what the problem is. You can go to |
I'm seeing this too. React 0.13.2. Tools appear to work fine on http://facebook.github.io/react/, but break on my site in development. Is it possible that it has trouble with asynchronous updates in general, or possibly asynchronous updates when there are multiple root nodes? |
The devtools should work fine with multiple roots. facebook.com has many, for instance. |
Perhaps we should update the title of this to "React-devtools only shows single TopLevel element" since we haven't been able to narrow it down to a particular version or module? |
I have stumbled upon this issue before, and it turned out to be a badly configured component embedding an instance of React of its own (SO link). There may be other causes, but can it be that updating the React dependency's version number has also triggered such anomalies in projects containing faulty components? |
@Enet4 that appears to be the issue, I'm checking with my colleagues |
Just adding a note to confirm @Enet4 diagnosis, I had the same problem, and traced it to react-intl including react as a dependency rather than peerDependency, with a >= version match that included a react 0.14 beta in addition the 0.13.3 version in my webpack bundle. I've supplied a pull request to fix react-intl but unfortunately they've closed it without merging indicating that react versions are something that can be controlled at the app level (?). Hopefully others find this info useful though as the dev tools are really useful to have working. |
Thank you @crafterm! Moving |
@crafterm Thanks, just commented on formatjs/formatjs#128. |
This is happening for me too, I've verified that none of my packages are pulling in an extra copy of React, they're all using peerDependency. |
@lyptt Can you provide that list of dependencies and how you are building your program? Either the building process is incorrectly including multiple copies of React (even with |
It's a dual server/client React app using Browserify and Reactify to handle pulling everything in client-side. For client side dependencies, I'm using browserify-middleware with express, as follows: browserify.settings('transform', [
reactify,
envify(process.env)
]);
browserify.settings('mode', config.debug ? 'development' : 'production');
app.use('/js/lib.js', browserify(['lodash', 'react', 'joi', 'react-validation-mixin', 'superagent', 'events', 'cookies-js']));
app.use('/js/app.js', browserify('./browser-app.js'));
var React = require("react"),
App = React.createFactory(require("./components/app.jsx"));
if (typeof window !== 'undefined') {
React.initializeTouchEvents(true);
window.onload = function () {
React.render(App(window.___APP_PROPS___), document.body, undefined);
};
} For server side, I'm using node-jsx to handle require with Node and JSX files, along with one centralized rendering function for each page: var renderPage = function(req, res, initialRoute, initialRouteData, user) {
var cookies = new Cookies(req, res, app.get('cookieSecret'));
var initialProperties = {
path: req.originalUrl,
currentUser: user,
authToken: cookies.get('auth-token'),
initialRoute: initialRoute,
initialRouteData: initialRouteData,
history: true
};
log.debug(initialProperties);
var element = React.createElement(require('../../components/app.jsx'), initialProperties);
var markup = React.renderToString(element);
res.render('index', {markup: markup, props: initialProperties});
}; Everything after that is just basic React components, that's the only special stuff I'm doing. As for a list of dependencies, here's the full list: "dependencies": {
"bluebird": "^2.9.30",
"body-parser": "~1.12.4",
"browserify-middleware": "^6.0.0",
"cookie-parser": "~1.3.5",
"cookies": "^0.5.0",
"cookies-js": "^1.2.1",
"debug": "~2.2.0",
"envify": "^3.4.0",
"express": "~4.12.4",
"jade": "~1.9.2",
"joi": "^6.5.0",
"lodash": "^3.9.3",
"morgan": "^1.6.0",
"node-jsx": "^0.13.3",
"node-sass-middleware": "^0.9.0",
"react": "^0.13.3",
"react-async": "^2.1.0",
"react-router-component": "^0.25.4",
"react-validation-mixin": "^4.1.0",
"reactify": "^1.1.1",
"serve-favicon": "~2.2.1",
"superagent": "^1.2.0",
"winston": "^1.0.0"
} Note that only the dependencies listed in the bundled |
|
I can't see any other versions of React in node_modules, nor in I do see two entries for React, one is My full file list is as follows:
Are there any telltale signs I should be looking for to see if another version of React is being bundled? I should also point out that I removed |
Well, running browserify with |
Yup, that helped! One of the components I've got required react with a capital R, which for some reason browserify resolved as a completely different module. I'll go log an issue there - thanks! |
@lyptt and @Enet4 Thanks heaps for that. Went through and found components requiring React with a captital R as well. Removed them and react tools work again. 👍 |
Is it worth documenting this as a known issue somewhere? |
I think so, according to browserify it's intended behavior that the same module is loaded twice if different casings are used: node-browserify - #1063. Either there should be a disclaimer about this, or it should be an error throw if we really shouldn't be loading React twice. |
See: facebook/react-devtools#90 If you have multiple copies of react.js, each one registers itself as the data source for the DevTools, and the last one wins.
We have a similar situation that arose when we extracted a simple component to be used in two apps. We are compiling the library using webpack, setting React as a peer dependency, listing all other dependencies as devDependencies. We have listed react as an external in the webpack config, an excerpt of which is here:
In our parent app, just importing this lib (even without using it) causes this issue. To make sure there was nothing tricky in what we were doing with the lib, I simplified the lib component to this:
When I inspect the devtools inspector I get this in localStorage under the key
We are using other third party React components (e.g. react-bootstrap), but with those we are not having this problem. Any ideas? |
The way that I've dealt with this is using webpack's resolve: {
alias: {
'react': path.join(__dirname, './node_modules/react'),
}
} This way it uses just one react even in other modules. |
Have we decided that the real issue here is having multiple versions of react loaded? |
Speaking only to my specific case, the alias trick didn't end up working, unfortunately. We ended up bringing the component back into the parent repo to dodge the issue outright. (I realize that isn't helpful. Hopefully if anyone else is seeing this, we can try again!) |
My case of including React multiple times seems to be a common cause for the problem, but I'm not sure if this is the only cause |
The alias fix by @jaredly for webpack worked for the project I'm on that also had the empty TopLevel problem. Some dependencies had |
@PCguru Are these open-source deps? Everyone should be doing |
Closing as outdated. |
The extension was working on our app until we updated to
react
0.13 version, all it shows is:The text was updated successfully, but these errors were encountered: