Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null #121

Closed
stevenmusumeche opened this issue Jun 14, 2017 · 11 comments

Comments

@stevenmusumeche
Copy link

Version

2.2.1

Test Case

http://jsbin.com/sacerobuxi/edit?html,js,output

Steps to reproduce

Unsure but it happens in production (rarely)

Expected Behavior

No uncaught errors

Actual Behavior

Line 76: Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null

        innerWidth = _window.innerWidth,
        innerHeight = _window.innerHeight;
        var rect = _this.menu.getBoundingClientRect(); // <-- error on this line
        var menuStyles = {
            top: y,
            left: x
@vkbansal
Copy link
Owner

It would be helpful if I can get steps to reproduce.

@stevenmusumeche
Copy link
Author

Yea, totally understand, I can't reproduce it either but our error tracking is finding it in the wild. I noticed a similar error which happens in the same file because _this.menu is null.

@vkbansal
Copy link
Owner

OK. I'll take a stab at it over the weekend.

@skipjack
Copy link

I'm seeing this as well:

image

Which stems from line 147 in ContextMenu.js. It's line 58 that triggers this though -- I think the window.requestAnimationFrame || setTimeout is causing it to be called after the component has unmounted in certain scenarios.

It's inconsistent for me as well though I am able to reproduce it consistently when changing urls via react-router. I don't have time to throw together an example at the moment but I'm pretty sure what I described above is the cause.

@skipjack
Copy link

skipjack commented Jun 15, 2017

Also seeing the following from the same block of code:

image

Which seems to be caused by trying to read styles after the component has unmounted.

@vkbansal
Copy link
Owner

Which browser are you guys seeing this on?

@skipjack
Copy link

Chrome for me.

@stevenmusumeche
Copy link
Author

Latest Chrome for me as well.

@vkbansal
Copy link
Owner

Released a patch for this. Please open issues if you find such errors in future.

@skipjack
Copy link

Tested and confirmed the fix, thanks @vkbansal!

@stevenmusumeche
Copy link
Author

same here, thanks so much @vkbansal you rock

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

No branches or pull requests

3 participants