Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Missing React element for debugID" warning when triggering a render in componentWillMount #7187

Closed
yannickcr opened this issue Jul 5, 2016 · 18 comments
Assignees

Comments

@yannickcr
Copy link

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
As reported by @adamryvola in #6869 (comment), React is displaying a warning Warning: ReactComponentTreeDevtool: Missing React element for debugID 2 when building stack when another component is rendered in componentWillMount

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/reactjs/69z2wepo/).

import React, {Component} from 'react';
import ReactDOM from 'react-dom';

const container = document.getElementById('container');
const menuContainer = document.getElementById('menu-container');

export default class App extends Component {

  componentWillMount() {
    ReactDOM.render(<div />, menuContainer);  // <= Trigger the warning
  }

  render() {
    return (
      <div>
        <div>App</div>
      </div>
    );
  }
}

ReactDOM.render(<App />, container);

JSFiddle: https://jsfiddle.net/0n3a6vp9/

What is the expected behavior?
According to @gaearon this warning is "against internal bugs in React, it's not meant for users" (source: #6869 (comment)) so this warning should not be triggered.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 15.2.0, no issue with React 0.14.7

@gaearon
Copy link
Collaborator

gaearon commented Jul 5, 2016

Interestingly, also appears triggered by ReactDOMServer usage inside render: #7190

@gaearon
Copy link
Collaborator

gaearon commented Jul 5, 2016

Okay, #7193 should fix it.

gaearon added a commit that referenced this issue Jul 5, 2016
* Add failing tests for #7187 and #7190

* Pass shouldHaveDebugID flag to instantiateComponent

This allows us to remove a hack that was added in #6770 and caused #7187 and #7190.

* Move logic for choosing whether to use debugID outside instantiate
@gaearon
Copy link
Collaborator

gaearon commented Jul 5, 2016

Fixed by #7193.

@gaearon gaearon closed this as completed Jul 5, 2016
@adamryvola
Copy link

Hello,
i created small project. It gives me this warring. Here is link: small-kit

Please, can you try it, and tell me, where is the problem? I cant find it.

I am very thankful for all your help!

@gaearon
Copy link
Collaborator

gaearon commented Jul 6, 2016

This is a bug in React and it should be fixed in master.
Please wait for the next release.
If it's not fixed for you in the next release, please file another issue.

zpao pushed a commit that referenced this issue Jul 8, 2016
* Add failing tests for #7187 and #7190

* Pass shouldHaveDebugID flag to instantiateComponent

This allows us to remove a hack that was added in #6770 and caused #7187 and #7190.

* Move logic for choosing whether to use debugID outside instantiate

(cherry picked from commit d2ff462)
@angusfretwell
Copy link

angusfretwell commented Jul 10, 2016

Hey,

I'm still getting this warning (specifically Warning: ReactComponentTreeDevtool: Missing React element for debugID X when building stack) when running tests with Jest.

@gaearon
Copy link
Collaborator

gaearon commented Jul 10, 2016

File an issue with the code reproducing it. Thank you!

@angusfretwell
Copy link

@gaearon Here you go: #7240 😸

usmanajmal pushed a commit to usmanajmal/react that referenced this issue Jul 11, 2016
* Add failing tests for facebook#7187 and facebook#7190

* Pass shouldHaveDebugID flag to instantiateComponent

This allows us to remove a hack that was added in facebook#6770 and caused facebook#7187 and facebook#7190.

* Move logic for choosing whether to use debugID outside instantiate
@kevinSuttle
Copy link
Contributor

npm install --save [email protected] - fixes this issue for me.

@maullerz
Copy link

maullerz commented Aug 1, 2016

for me "15.3.0-rc.3" and "15.3.0" not fixes issue

@gaearon
Copy link
Collaborator

gaearon commented Aug 1, 2016

for me "15.3.0-rc.3" and "15.3.0" not fixes issue

@maullerz This issue is about Jest. Are you using Jest? Can you provide a sample project demonstrating the issue?

@maullerz
Copy link

maullerz commented Aug 1, 2016

@gaearon no, i dont use Jest.
If it helps, i see this errors only in my bash console, when i run koa with server-side rendering, and using Jade as template.

@xuqingkuang
Copy link

@gaearon Please have a look at my simple boilerplate - https://github.com/xuqingkuang/react-redux-boilerplate

When execute gulp test the warning will appear.

@gaearon
Copy link
Collaborator

gaearon commented Aug 12, 2016

Thanks for a repro case.
I’ll reopen and get back to it after fixing some other issues I’m working on right now.

@gaearon gaearon reopened this Aug 12, 2016
@AshCoolman
Copy link

AshCoolman commented Aug 18, 2016

Hack: filter test output

Installation

Save the following file in the root of your project

./test-run-filter.js

var spawn = require('child_process').spawn;
console.log('Run like this: node ./test-run-filter.js  "npm test"');
var ls = spawn(process.argv[2], {shell:true});
ls.stdout.on('data', (data) => {
  if (data.indexOf('Missing React element for debugID') === -1) {
    console.log(data);  
  }
});

ls.stderr.on('error', (data) => {
  console.log(data);
});

ls.on('close', (code) => {
  console.log(code);
});

Usage

$ node ./test-run-filter.js "npm run test"

Conclusion

◔ᴗ◔

@gaearon
Copy link
Collaborator

gaearon commented Aug 20, 2016

This was fixed in React 15.3.1.
Confirmed by following instructions in #7187 (comment).

@gaearon gaearon closed this as completed Aug 20, 2016
@Raibaz
Copy link

Raibaz commented Oct 7, 2016

I'm still experiencing this on 15.3.2 when running mocha to execute tests :(

@gaearon
Copy link
Collaborator

gaearon commented Oct 7, 2016

Please file an issue with a test case reproducing it. I'm afraid we can't help otherwise.

(But also run npm ls react just to make sure you are on 15.3.2.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants