Skip to content

Commit

Permalink
refactor: allow custom impl of backend realod-to-profile support check
Browse files Browse the repository at this point in the history
  • Loading branch information
EdmondChuiHW committed Sep 26, 2024
1 parent a474aa8 commit 9516532
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/react-devtools-shared/src/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import Agent from './agent';

import type {DevToolsHook, RendererID, RendererInterface} from './types';
import {isSynchronousXHRSupported} from './utils';

export type InitBackend = typeof initBackend;

Expand Down Expand Up @@ -103,3 +104,15 @@ export function initBackend(
subs.forEach(fn => fn());
};
}

function defaultGetIsReloadAndProfileSupported(): boolean {
// Notify the frontend if the backend supports the Storage API (e.g. localStorage).
// If not, features like reload-and-profile will not work correctly and must be disabled.
let isBackendStorageAPISupported = false;
try {
localStorage.getItem('test');
isBackendStorageAPISupported = true;
} catch (error) {}

return isBackendStorageAPISupported && isSynchronousXHRSupported();
}

0 comments on commit 9516532

Please sign in to comment.