mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Make DevTools Websocket retry delay configurable (#20107)
This commit is contained in:
@@ -24,6 +24,7 @@ The `config` object may contain:
|
||||
* `useHttps: boolean` (defaults to `false`) - Websocked should use a secure protocol (wss).
|
||||
* `websocket: Websocket` - Custom websocket to use. Overrides `host` and `port` settings if provided.
|
||||
* `resolveRNStyle: (style: number) => ?Object` - Used by the React Native style plug-in.
|
||||
* `retryConnectionDelay: number` (defaults to `2000`) - Milliseconds delay to wait between retrying a failed Websocket connection.
|
||||
* `isAppActive: () => boolean` - If provided, DevTools will poll this method and wait until it returns true before connecting to React.
|
||||
|
||||
## `react-devtools-core/standalone`
|
||||
|
||||
+6
-1
@@ -26,6 +26,7 @@ type ConnectOptions = {
|
||||
port?: number,
|
||||
useHttps?: boolean,
|
||||
resolveRNStyle?: ResolveNativeStyle,
|
||||
retryConnectionDelay?: number,
|
||||
isAppActive?: () => boolean,
|
||||
websocket?: ?WebSocket,
|
||||
...
|
||||
@@ -60,6 +61,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
|
||||
port = 8097,
|
||||
websocket,
|
||||
resolveRNStyle = null,
|
||||
retryConnectionDelay = 2000,
|
||||
isAppActive = () => true,
|
||||
} = options || {};
|
||||
|
||||
@@ -69,7 +71,10 @@ export function connectToDevTools(options: ?ConnectOptions) {
|
||||
function scheduleRetry() {
|
||||
if (retryTimeoutID === null) {
|
||||
// Two seconds because RN had issues with quick retries.
|
||||
retryTimeoutID = setTimeout(() => connectToDevTools(options), 2000);
|
||||
retryTimeoutID = setTimeout(
|
||||
() => connectToDevTools(options),
|
||||
retryConnectionDelay,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user