-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Suppress "Download the React DevTools" log for a better development experience #24283
Comments
Set REACT_DEVTOOLS_GLOBAL_HOOK environment is not a good idea because pmmmwh/react-refresh-webpack-plugin#475 |
Hey! Thanks for reporting this issue. I'm a little unclear about your issue. Could you give more details on how to reproduce? What do you mean by a remote debug Chrome DevTools window? Why can't Chrome extensions be used there? |
To reproduce this is a little complex, you may need to install photoshop or affect and config the debug model... |
Right. React DOM logs a suggestion to install React DevTools on environments where DevTools isn't installed, which it identifies by checking to see if Regarding the developer experience, I understand why it might be a small inconvenience although there are many other things that also log in DEV mode (like the HMR logs in your screenshot above). If it's a huge problem, we could add an opt-out mechanism (probably another global variable) but I'm not convinced that's worth it. |
I did suggest overriding it in the past as a workaround for this log: #11448. I'm not particularly fond of that approach, but wanted to share as an explanation for why people are trying that pattern. It's referenced in #3877 which people find by googling. |
@gaearon Maybe worth editing that old message to remove the recommendation (or clarify that it technically works but we don't recommend it) if it's causing confusion? Overriding the hook feels kind of sketchy to me as it could easily cause runtime errors that get misattributed to React or DevTools. (This has happened before, although I don't remember the issue numbers.) |
If we remove the suggestion, it feels like we should also reopen that issue since it was a very popular request, and now it has no solution... I wonder if there's some stopgap solution that we can expect to work indefinitely. If we're saying that this is no longer (tacitly) supported, we should also remove this code: react/packages/react-reconciler/src/ReactFiberDevToolsHook.new.js Lines 63 to 68 in ece5295
|
I think that specifying some other global boolean (that DevTools and React both could read and respect) feels less fragile than encouraging people to override the hook. In general, I'm wary of any code that overrides the hook. Edit: I don't feel strongly about this. I just think it's hacky and fragile to suggest people disable the warning by overriding the hook. If the response to that is concern that we recommend it on an old GitHub issue, then it seems like we can edit that recommendation. I'm not opposed to some opt-out mechanism for the warning itself. DevTools doesn't even need to be involved in that. I'm also not opposed to an opt-out mechanism for DevTools integration. I'm just concerned about people overriding or messing with the hook/internal API.
|
👍 |
I'd like to take it, if it's possible. |
Sure! |
just an fyi that this issue is not forgotten, I'll look at it this/next week, got sick just after I said I want to take it :-/ |
any progress? |
https://github.com/bearow/react/tree/suppress-devtools-logs-flag I'm not sure if I did it as you guys imagined it. Also I'm currently struggling a little with testing it manually to check if it works as intended. Sorry for the slow progress. (when I test it out I'll rebase and create a PR) |
Having an official method to remove the ad is better than having people hack together a fix that may have unintended consequences. Looking forward for updates on this! |
hi, @bearow , It has been more than 10 weeks since you take this issue. If you don't mind, I would like to make a Pull Request to fix this issue. |
@JuniorTour sure, go ahead - I got overwhelmed by life :-/ |
It is incredible that we can't disable this nasty message 😢 |
One can proxy try {
console.info = new Proxy(console.info, {
apply: (target, thisArg, args) => {
if (args?.[0]?.includes?.("React DevTools")) return;
return Reflect.apply(target, thisArg, args);
},
});
} catch {} Would strongly suggest react to just drop this silly advertisement. |
Any updates here? I see this annoying message when running unit tests and it makes the output unnecessarily noisy. Example:
|
I can confirm @kaiyoma issue, warning is thrown when running vitest application |
I noticed this in vitest, after upgrading from v0.34.1 to v0.34.2. I also noticed it happens when using happy-dom as the environment, not jsdom. So I think it may be something to do with "Pass environmentOptions to happy-dom integration" mentioned in the v0.34.2 release notes. As a temporary workaround I'm using jsdom instead of happy-dom, but that is because I was having another issue with happy-dom. Another alternative would be to ensure vitest is locked to version 0.34.1 and no higher. |
I'm not sure why it started to happen in that particular release, but the reason for why you get this error message in Happy DOM is because of this check in React: if (
(navigator.userAgent.indexOf('Chrome') > -1 &&
navigator.userAgent.indexOf('Edge') === -1) ||
navigator.userAgent.indexOf('Firefox') > -1
) It matches the default user agent in Happy DOM, but not in JSDOM. As a temporary fix you can use |
This has now been fixed in Happy DOM v12. Happy DOM will no longer be detected as a supported browser when using the default user agent. |
React version: 18.0.0
Steps To Reproduce
Link to code example:
The current behavior
The expected behavior
No this message. Chrome extension can't be used in remote debug window
The text was updated successfully, but these errors were encountered: