-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast Refresh: Improve dev experience when DevTools hook is disabled #20117
Comments
What browser extensions are installed on your local machine? It seems like something else might be interfering with the react/packages/react-devtools-shared/src/backend/index.js Lines 90 to 93 in 779a472
react/packages/react-refresh/src/ReactFreshRuntime.js Lines 482 to 485 in 779a472
DevTools initializes the hook with a react/packages/react-devtools-shared/src/hook.js Lines 313 to 325 in 779a472
Fast Refresh does the same if DevTools wasn't around to initialize the hook: react/packages/react-refresh/src/ReactFreshRuntime.js Lines 439 to 442 in 779a472
So my guess is that you have some other extension installed (possibly even a really old version of React DevTools?) that's initializing |
I have set up the React DevTools 4.9.0(last version) - to my host machine, and now i have no problem on it, on virtual machine then I have my dev envirironment(phpstorm, create-react app etc.) I have no problem as erlier. Indeed all problem was in the DevTools didn't installed on my host machine?! (excause me for my bad english). I checked it and I saw that problem was in it! |
No. The React DevTools extension should not be required. Fast Refresh will check to see if DevTools isn't installed and will initialize the hook itself: react/packages/react-refresh/src/ReactFreshRuntime.js Lines 439 to 466 in 779a472
My guess was that something else (another extension?) was initializing the hook so that this Fast Refresh check didn't pass:
But this line later throws:
|
@Sinsstranger Can you reproduce this error in an incognito window (with all extensions disabled)? |
Yes i have this problem with it bouth incognito, and not incognito mode with all extensions disabled |
@Sinsstranger If you log |
The output logged by this machine does not look like anything we (React or DevTools) inject. Something else is setting the value of Can you add this code to your app (at the top, before other scripts are loaded) and see if it logs anything? let hook;
Object.defineProperty(window, '__REACT_DEVTOOLS_GLOBAL_HOOK__', {
get() {
return hook;
},
set(value) {
console.trace('hook initialized:', value);
hook = value;
}
}); |
Do you use React with any third-party renderers? |
I has same problem, update the React DevTools extensions version and fixed it |
@VoliBearCat Maybe you were using v3 of DevTools? Browsers should auto-update the extension though, and v4 has defined a The value logged above doesn't even look like the hook that v3 used though, except that it defines an |
Maybe something intentionally trying to block the (DEV only) console log telling people to install the DevTools extension? The fact that there's an |
@gaearon Should Fast Refresh check the |
Sure, happy to take a PR if someone wants to make it. |
I recently used Fast Refresh. my co-worker didn't use VPN so she can't update extensions from google. we reside in China. :-P |
Makes sense. Hope you like the new DevTools! 😄 Here's a guide that explains some of the things that changed between v3 and v4: And here's an interactive tutorial: |
Is anybody working on this issue? I will love to take it. |
@alphabet-codes No one has started it to my knowledge. (If they had, there would be a comment on this issue.) Feel free! Check out my updated description for what I think is the desired outcome now. |
@bvaughn Can i fix this issue? I have already started working on it though 😆 (P.S: Do we need to have a test case for it? If yes, i will have to possibly add a new test file with partial devtools injected and expecting a warning in console) |
As per "How to contribute", i am leaving a comment that i am working on this issue 😸 |
Test case would be nice. |
@mrfambo I'm currently working on this. Thanks for the attention. |
@alphabet-codes sure sure. I will take some other issue ❤️ |
@mrfambo cool 😎 |
…ble handling of dev tools global hook being disabled
I think this issue should be closed, as its fixed by the above linked PR |
Seems reasonable. |
If anyone else is watching and looking for an explanation. The browser extension, which was not even close to development at all, blocked and this problem appeared |
The crash is likely being caused by some third party code (possibly a browser extension) injecting a partial DevTools hook into the page. (See below comments for more information.)
We can't prevent this but Fast Refresh could more gracefully handle this case by checking to see if
window. __REACT_DEVTOOLS_GLOBAL_HOOK__.isDisabled
is true (like we do here). Rather than crash, Fast Refresh could print a warning to the console in DEV mode saying that it won't run because of the disabled hook override.Original report: Crash with "hook.renderers is undefined"
I have a bit problem, when i just do
yarn create react-app name --template redux
, and start it to learn how to develop - I saw next:On localhost(it's vmware virtualhost) I have no problem, but on host machine i see Uncaught TypeError: hook.renderers is undefined in js console, and empty body
How can I handle it? And what this error means in general?
The text was updated successfully, but these errors were encountered: