@samitouri / QOS-React-2 / commits / ba932a5ad9

fix: inspect ClassComponent.render instead of constructor, fixes #16749 (#16759)

Anton Korzunov committed Sep 13, 2019 at 01:32 UTC ba932a5ad953d7cb36bca273cfeab7eac5700f82
1 file changed +12 -1
packages/react-devtools-extensions/src/utils.js
+12 -1
@@ -12,10 +12,21 @@ export function createViewElementSource(bridge: Bridge, store: Store) {
12
13 setTimeout(() => {
14 // Ask Chrome to display the location of the component function,
15 + // or a render method if it is a Class (ideally Class instance, not type)
16 // assuming the renderer found one.
17 chrome.devtools.inspectedWindow.eval(`
18 if (window.$type != null) {
18 - inspect(window.$type);
19 + if (
20 + window.$type &&
21 + window.$type.prototype &&
22 + window.$type.prototype.isReactComponent
23 + ) {
24 + // inspect Component.render, not constructor
25 + inspect(window.$type.prototype.render);
26 + } else {
27 + // inspect Functional Component
28 + inspect(window.$type);
29 + }
30 }
31 `);
32 }, 100);