Skip to content
This repository has been 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

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

wants to merge 1 commit into from

Conversation

macku
Copy link

@macku macku commented Oct 23, 2018

There is a problem with a Show <Component> Source feature when you are running React with React Hot Loader. After selecting the option from a context menu, you will be navigated to a React Hot Loader ProxyFacade component instead of the source of a selected component.

How to reproduce?

  1. Go to this page: https://jnwlwrm1qw.codesandbox.io/
  2. Open React Devtools
  3. Select App component on the Elements tab
  4. From the context menu select Show App Source

Current behavior

Devtools are activating Source tab and highlighting ProxyFacade that is coming from React Hot Loader.

Expected behavior

Devtools should go to the Source tab and highlight the source of App component.

Demo

rhl-bug

@@ -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.

@theKashey
Copy link

Would be fixed in Rect 4.5.0 via option pureRender (disabled by default, yet)

@theKashey
Copy link

Probably you can close this issue now.
React-Hot-Loader 4.5.4 is going live tonight.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants