Skip to content

how to debug Cannot read property '__reactInternal .... of null ? #8091

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

Closed
manikanta-kotha opened this issue Oct 25, 2016 · 9 comments
Closed
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@manikanta-kotha
Copy link

is there any good debugging toool for finding the exact line numbers or Component names where we got the error like
Uncaught TypeError: Cannot read property '__reactInternalInstance$mdm22afavg17ndrawaq8e61or' of null
is only adding console logs for every file is the solution ????????

@gaearon
Copy link
Collaborator

gaearon commented Oct 26, 2016

If you have an error like this, you likely have an earlier error which got React into an inconsistent state. If you use Promises, you might be catching those errors by mistake, and so they never appear in the console.

If you think this is a React bug, please provide a fiddle reproducing the issue.

@gaearon gaearon added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Oct 26, 2016
@aweary
Copy link
Contributor

aweary commented Oct 31, 2016

Closing due to lack of details and no response.

@aweary aweary closed this as completed Oct 31, 2016
@randallb
Copy link

Can you better define getting react into an inconsistent state? What are common problems that would lead this to happen?

@gaearon
Copy link
Collaborator

gaearon commented Feb 17, 2017

If React component throws in a render or a lifecycle method, it is likely to get into that state.
The next update to an already broken tree will throw these meaningless errors.

This will be fixed in future versions (in which we'll support error boundaries).

@gaearon
Copy link
Collaborator

gaearon commented Jul 27, 2017

A small update on this. We just released React 16 beta which shouldn’t emit cryptic errors like this one. Even if the application code swallows an error, React 16 will still print it to the console. It might be too early for you to try React 16 (since ecosystem is still preparing for it), but this error should never occur in the future after you switch to it.

@discrete-javascript
Copy link

I have an example how this error appeared.

it('should componentDidMount', () => {
        const wrapper = ReactTestUtils.renderIntoDocument(<Component />);
        wrapper.updater.isMounted();
    });

Right now we are using 15.5.

@cancerberoSgx
Copy link

Make sure to call wrapper.update() before the method is throwing the error (like wrapper.simulate()). I think that of error is thrown (enzyme) when the wrapper points to nodes that no longer exists (because the page was re-rendered or the original nodes replaced/changed for some reason ). update() solved the problem in my case ( error thrown when calling wrapper.simulate() - working with enzyme / jsdom)

@coxato
Copy link

coxato commented Oct 31, 2020

In my case was a little mistake, I was doing wrapper.simulate('submit') instead of wrapper.find('form').simulate('submit')

@tur-nr
Copy link

tur-nr commented Oct 17, 2022

I recently faced this issue within Enzyme. It turns out that you cannot .simulate() on a Fragment, so you just need to dive a little deeper in the tree to be able to simulate. I found this out because a third-party library changed their node structure to use Fragments.

- wrapper.find(Icon).simulate('click');
+ wrapper.find(Icon).find('span').simulate('click');

Hope this helps anyone else lost by the cryptic error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

8 participants