Skip to content

Commit

Permalink
dx: better error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMueller-OneAndOnly committed Dec 13, 2023
1 parent 2542c6a commit a9db3e1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/click-to-react-component/src/getSourceForElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export function getSourceForElement(

function getFirstParentElementWithSource(element) {
const parentElement = element.parentElement
if (parentElement === null) throw new Error('No parent found')
if (parentElement === null) {
console.warn("Couldn't find a React instance for the element", element)
throw new Error('No parent found for element')
}

const instance = getReactInstanceForElement(parentElement)
const source = getSourceForInstance(instance)
Expand Down

0 comments on commit a9db3e1

Please sign in to comment.