Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Fix showing component source when React Hot Loader is enabled #1191

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion shells/webextension/src/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ var config: Props = {
window.${globalPathToType}.prototype &&
window.${globalPathToType}.prototype.isReactComponent
) {
inspect(window.${globalPathToInst}.render);
if (window.${globalPathToInst}.REACT_HOT_LOADER_RENDERED_GENERATION) {
Copy link
Author

@macku macku Oct 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The REACT_HOT_LOADER_RENDERED_GENERATION property is assigned by React Hot Loader. Thanks to this property we can know that we are running RHL.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would not work for SFC, as long they are not in the prototype.
The only way to access "original" component is to use window.${globalPathToInst}.__reactstandin__getCurrent(link), but this is something react-dev-tools should not rely on.

inspect(Object.getPrototypeOf(window.${globalPathToType}));
} else {
inspect(window.${globalPathToInst}.render);
}
} else {
inspect(window.${globalPathToType});
}
Expand Down