You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Must be called before packages like react or react-native are imported
20
-
connectToDevTools({
21
-
...config
22
-
});
21
+
connectToDevTools({...config});
23
22
}
24
23
```
25
24
26
25
> **NOTE** that this API (`connectToDevTools`) must be (1) run in the same context as React and (2) must be called before React packages are imported (e.g. `react`, `react-dom`, `react-native`).
|`settings`| Optional. If not specified, or received as null, then default settings are going to be applied: appending component stacks to error messages and displaying inline errors and warnings.<br/>Can be plain object or a Promise that resolves with the plain object with [these boolean fields](https://github.com/facebook/react/blob/20cec76c44f77e74b3a85225fecab5a431cd986f/packages/react-devtools-shared/src/backend/types.js#L531-L536). If Promise rejects, the console will not be patched and some console features from React DevTools will not work. |
31
+
28
32
### `connectToDevTools` options
29
-
| Prop | Default | Description |
30
-
|---|---|---|
31
-
|`host`|`"localhost"`| Socket connection to frontend should use this host. |
32
-
|`isAppActive`|| (Optional) function that returns true/false, telling DevTools when it's ready to connect to React. |
33
-
|`port`|`8097`| Socket connection to frontend should use this port. |
34
-
|`resolveRNStyle`|| (Optional) function that accepts a key (number) and returns a style (object); used by React Native. |
35
-
|`retryConnectionDelay`|`200`| Delay (ms) to wait between retrying a failed Websocket connection |
36
-
|`useHttps`|`false`| Socket connection to frontend should use secure protocol (wss). |
37
-
|`websocket`|| Custom `WebSocket` connection to frontend; overrides `host` and `port` settings. |
|`onSubscribe`| Function, which receives listener (function, with a single argument) as an argument. Called when backend subscribes to messages from the other end (frontend). |
44
-
|`onUnsubscribe`| Function, which receives listener (function) as an argument. Called when backend unsubscribes to messages from the other end (frontend). |
45
-
|`onMessage`| Function, which receives 2 arguments: event (string) and payload (any). Called when backend emits a message, which should be sent to the frontend. |
|`onSubscribe`| Function, which receives listener (function, with a single argument) as an argument. Called when backend subscribes to messages from the other end (frontend). |
49
+
|`onUnsubscribe`| Function, which receives listener (function) as an argument. Called when backend unsubscribes to messages from the other end (frontend). |
50
+
|`onMessage`| Function, which receives 2 arguments: event (string) and payload (any). Called when backend emits a message, which should be sent to the frontend. |
51
+
|`onSettingsUpdated`| A callback that will be called when the user updates the settings in the UI. You can use it for persisting user settings. |
46
52
47
53
Unlike `connectToDevTools`, `connectWithCustomMessagingProtocol` returns a callback, which can be used for unsubscribing the backend from the global DevTools hook.
0 commit comments