From 6797b3666f30b09e3964eac152e36bb377ef8c83 Mon Sep 17 00:00:00 2001 From: Raphael Gaschignard Date: Sun, 28 Apr 2024 09:16:38 +1000 Subject: [PATCH] [react-dom] Provide a way to silence devtools recommendation If you hit this console message and search for how to turn it off, many people recommend hacky ways to do so that also end up breaking the extension if you actually want to use it later on. This provides a way to turn off just the message, without trying to trick injectIntoDevTools into thinking something's happened. --- packages/react-dom/src/client/ReactDOMClient.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-dom/src/client/ReactDOMClient.js b/packages/react-dom/src/client/ReactDOMClient.js index 036fd846a47b..c41f8275aae3 100644 --- a/packages/react-dom/src/client/ReactDOMClient.js +++ b/packages/react-dom/src/client/ReactDOMClient.js @@ -57,7 +57,12 @@ const foundDevTools = injectIntoDevTools({ }); if (__DEV__) { - if (!foundDevTools && canUseDOM && window.top === window.self) { + if ( + !foundDevTools && + canUseDOM && + window.top === window.self && + !window.__DONT_RECOMMEND_REACT_DEVTOOLS__ + ) { // If we're in Chrome or Firefox, provide a download link if not installed. if ( (navigator.userAgent.indexOf('Chrome') > -1 &&