@whereby.com/browser-sdk 3.37.0 → 3.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,6 +28,47 @@ pnpm add @whereby.com/browser-sdk
28
28
 
29
29
  ### React hooks
30
30
 
31
+ #### WherebyProvider
32
+
33
+ Render `WherebyProvider` above every component that uses the hooks. By default it
34
+ creates its own `WherebyClient` and destroys it when the provider unmounts.
35
+
36
+ ```js
37
+ import { WherebyProvider } from "@whereby.com/browser-sdk/react";
38
+
39
+ function App() {
40
+ return (
41
+ <WherebyProvider>
42
+ <MyCallUX />
43
+ </WherebyProvider>
44
+ );
45
+ }
46
+ ```
47
+
48
+ If your app keeps logic outside React, for example in a Redux store, create the
49
+ client yourself and pass it in with the `client` prop. Code outside React can
50
+ then call the client and subscribe to its events, while the hooks inside the
51
+ provider use the same client.
52
+
53
+ ```js
54
+ import { WherebyClient, WherebyProvider } from "@whereby.com/browser-sdk/react";
55
+
56
+ const client = new WherebyClient();
57
+ const store = createAppStore({ client }); // your own state layer
58
+
59
+ function App() {
60
+ return (
61
+ <WherebyProvider client={client}>
62
+ <MyCallUX />
63
+ </WherebyProvider>
64
+ );
65
+ }
66
+ ```
67
+
68
+ You own a client you pass in: the provider never calls `destroy()` on it, so it
69
+ survives the provider unmounting and remounting. Call `client.destroy()`
70
+ yourself when you no longer need it.
71
+
31
72
  #### useLocalMedia
32
73
 
33
74
  The `useLocalMedia` hook enables preview and selection of local devices (camera