WarnIfLegacyBackendDetected() — react Function Reference
Architecture documentation for the WarnIfLegacyBackendDetected() function in WarnIfLegacyBackendDetected.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD bedec864_08f7_8a04_2126_8804d0f4842c["WarnIfLegacyBackendDetected()"] 87fd0981_62e7_8a4e_e24c_67f948fec1d9["WarnIfLegacyBackendDetected.js"] bedec864_08f7_8a04_2126_8804d0f4842c -->|defined in| 87fd0981_62e7_8a4e_e24c_67f948fec1d9 style bedec864_08f7_8a04_2126_8804d0f4842c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/views/WarnIfLegacyBackendDetected.js lines 17–76
export default function WarnIfLegacyBackendDetected(_: {}): null {
const bridge = useContext(BridgeContext);
const {dispatch} = useContext(ModalDialogContext);
// Detect pairing with legacy v3 backend.
// We do this by listening to a message that it broadcasts but the v4 backend doesn't.
// In this case the frontend should show upgrade instructions.
useEffect(() => {
// Wall.listen returns a cleanup function
let unlisten: $FlowFixMe = bridge.wall.listen(message => {
switch (message.type) {
case 'call':
case 'event':
case 'many-events':
// Any of these types indicate the v3 backend.
dispatch({
canBeDismissed: false,
id: 'WarnIfLegacyBackendDetected',
type: 'SHOW',
title: 'DevTools v4 is incompatible with this version of React',
content: <InvalidBackendDetected />,
});
// Once we've identified the backend version, it's safe to unsubscribe.
if (typeof unlisten === 'function') {
unlisten();
unlisten = null;
}
break;
default:
break;
}
switch (message.event) {
case 'isBackendStorageAPISupported':
case 'isNativeStyleEditorSupported':
case 'operations':
case 'overrideComponentFilters':
// Any of these is sufficient to indicate a v4 backend.
// Once we've identified the backend version, it's safe to unsubscribe.
if (typeof unlisten === 'function') {
unlisten();
unlisten = null;
}
break;
default:
break;
}
});
return () => {
if (typeof unlisten === 'function') {
unlisten();
unlisten = null;
}
};
}, [bridge, dispatch]);
return null;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does WarnIfLegacyBackendDetected() do?
WarnIfLegacyBackendDetected() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/WarnIfLegacyBackendDetected.js.
Where is WarnIfLegacyBackendDetected() defined?
WarnIfLegacyBackendDetected() is defined in packages/react-devtools-shared/src/devtools/views/WarnIfLegacyBackendDetected.js at line 17.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free