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.

Try find parent when couldn't find a React instance ( has source) for the element

See original GitHub issue
export function getSourceForElement(
  /**
   * @type {HTMLElement}
   */
  element
) {
  const instance = getReactInstanceForElement(element)
  const source = getSourceForInstance(instance)

  if (source) return source

  console.warn("Couldn't find a React instance for the element", element)
}

Now in getSourceForElement, when we can’t find source of an element, we just return undefined.

Can we try to find a parent React instance which has a source?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
moroshkocommented, Apr 28, 2022

Potentially related, I’m getting an error when Option+clicking an element:

Screen Shot 2022-04-28 at 5 15 23 pm
Couldn't find a React instance for the element <div data-click-to-component-target=​"HOVER" style=​"position:​ fixed;​ z-index:​ 9999;​ inset:​ 16px;​ pointer-events:​ none;​">​</div>​
getSourceForElement @ getSourceForElement.js?be65:19
handleClick @ ClickToComponent.js?6fa9:42
getPathToSource.js?2ef7:12 Uncaught TypeError: Cannot read properties of undefined (reading 'columnNumber')
    at getPathToSource (getPathToSource.js?2ef7:12:1)
    at handleClick (ClickToComponent.js?6fa9:43:37)
3reactions
ericclemmonscommented, Apr 29, 2022

Ah, good point! If Babel isn’t transpiling a 3rd party lib’s JSX (because it’s already React.createElement), then there won’t be any __source.

This looks like an easy fix that I should be able to reproduce, too!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Could not find "store" in either the context ...
It's pretty simple. You're trying to test the wrapper component generated by calling connect()(MyPlainComponent) .
Read more >
Error: "Cannot add child "18903" to parent "18774" because ...
The reason DevTools throws is that the Progress Fiber's owner (the _debugOwner attribute) points to a Body Fiber that hasn't been mounted yet....
Read more >
Troubleshooting Guide - React Flow
A possible solution is to wrap your component with a <ReactFlowProvider /> or move the code that is accessing the state inside a...
Read more >
Forwarding Refs - React
const FancyButton = React.forwardRef((props, ref) => ( <button ref={ref} className="FancyButton"> {props.children} </button> )); // You can now get a ref ...
Read more >
Troubleshooting | React Navigation
This can happen if you are passing non-serializable values such as class instances, functions etc. in params. React Navigation warns you in this...
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