Skip to content

Commit 9aca239

Browse files
Improved dev experience when DevTools hook is disabled (#20208)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
1 parent 12627f9 commit 9aca239

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/react-refresh/src/ReactFreshRuntime.js

+11
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,17 @@ export function injectIntoGlobalHook(globalObject: any): void {
465465
};
466466
}
467467

468+
if (hook.isDisabled) {
469+
// This isn't a real property on the hook, but it can be set to opt out
470+
// of DevTools integration and associated warnings and logs.
471+
// Using console['warn'] to evade Babel and ESLint
472+
console['warn'](
473+
'Something has shimmed the React DevTools global hook (__REACT_DEVTOOLS_GLOBAL_HOOK__). ' +
474+
'Fast Refresh is not compatible with this shim and will be disabled.',
475+
);
476+
return;
477+
}
478+
468479
// Here, we just want to get a reference to scheduleRefresh.
469480
const oldInject = hook.inject;
470481
hook.inject = function(injected) {

0 commit comments

Comments
 (0)