question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'contains' of null

See original GitHub issue

What error is this? How to solve?

OutsideClickHandler.js:1 Uncaught TypeError: Cannot read property 'contains' of null
    at OutsideClickHandler.onOutsideClick (webpack:///./~/react-dates/lib/components/OutsideClickHandler.js?:1:3926)
    at eval (webpack:///./~/consolidated-events/lib/TargetEventHandlers.js?:1:1684)
    at Array.forEach (native)
    at TargetEventHandlers.handleEvent (webpack:///./~/consolidated-events/lib/TargetEventHandlers.js?:1:1620)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
ConAntonakoscommented, Aug 3, 2017

Sorry to bump this issue, but I seem to have also encountered this error message.

I think the issue is that I have my own <OutsideClickHandler> wrapping the react-dates component which also has its own OutsideClickHandler. When the component is removed from the VirtualDOM, I think it tries to trigger the OutsideClickHandler internally?

Would it be beneficial to the library to have a conditional wrapping this portion?: https://github.com/airbnb/react-dates/blob/master/src/components/OutsideClickHandler.jsx#L38

Something like if (this.childNode)?

Or maybe, allow onOutsideClick as a prop to <DateRangePicker>?

Also, another thing that helped was removing the consolidated-events API from use within my custo m <OutsideClickHandler>. For some reason that was causing issues.

4reactions
ljharbcommented, Aug 23, 2017

I think I’ve found a fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'contains' of null - Stack Overflow
I think your ref might be undefined after change to new page. So contains method is null . I don't have enough information...
Read more >
[Solved] TypeError: Cannot read property 'contains' of null
The error I'm seeing is TypeError: Cannot read property 'contains' of null . It's like SSR is trying to manipulate a DOM that...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >
Uncaught TypeError: Cannot read property 'contains ... - GitHub
Thank you for reporting this issue. Looks like lightGallery is not initialized properly. Could you please share the HTML and JavaScript code ...
Read more >
TypeError: Cannot read property 'contains' of undefined
The program complains about the following line of code. I put in the line of code above it to make sure that grabbed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found