Skip to content

Commit

Permalink
fix: inspect ClassComponent.render instead of constructor, fixes #16749
Browse files Browse the repository at this point in the history
… (#16759)
  • Loading branch information
theKashey authored and Brian Vaughn committed Sep 12, 2019
1 parent 35a202d commit ba932a5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/react-devtools-extensions/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ export function createViewElementSource(bridge: Bridge, store: Store) {

setTimeout(() => {
// Ask Chrome to display the location of the component function,
// or a render method if it is a Class (ideally Class instance, not type)
// assuming the renderer found one.
chrome.devtools.inspectedWindow.eval(`
if (window.$type != null) {
inspect(window.$type);
if (
window.$type &&
window.$type.prototype &&
window.$type.prototype.isReactComponent
) {
// inspect Component.render, not constructor
inspect(window.$type.prototype.render);
} else {
// inspect Functional Component
inspect(window.$type);
}
}
`);
}, 100);
Expand Down

0 comments on commit ba932a5

Please sign in to comment.