@dynamic-labs-sdk/react-hooks 1.19.0 → 1.19.1
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 +17 -13
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -5,41 +5,45 @@ React hooks for the Dynamic SDK client. Provides reactive state bindings for use
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @dynamic-labs-sdk/react-hooks @dynamic-labs-sdk/client react
|
|
8
|
+
npm install @dynamic-labs-sdk/react-hooks @dynamic-labs-sdk/client @tanstack/react-query react
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
These hooks are built on `@tanstack/react-query`, so your app needs a `QueryClientProvider` in addition to `DynamicProvider`. Wrap your app with both and pass your client instance:
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
16
17
|
import { createDynamicClient } from '@dynamic-labs-sdk/client';
|
|
17
18
|
import { DynamicProvider } from '@dynamic-labs-sdk/react-hooks';
|
|
18
19
|
|
|
19
20
|
const client = createDynamicClient({ environmentId: 'your-env-id' });
|
|
21
|
+
const queryClient = new QueryClient();
|
|
20
22
|
|
|
21
23
|
function App() {
|
|
22
24
|
return (
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
25
|
+
<QueryClientProvider client={queryClient}>
|
|
26
|
+
<DynamicProvider client={client}>
|
|
27
|
+
<MyComponent />
|
|
28
|
+
</DynamicProvider>
|
|
29
|
+
</QueryClientProvider>
|
|
26
30
|
);
|
|
27
31
|
}
|
|
28
32
|
```
|
|
29
33
|
|
|
30
|
-
Then use the hooks in any child component
|
|
34
|
+
Then use the hooks in any child component. Each hook returns the underlying `@tanstack/react-query` result object, so the value you want is under `.data`:
|
|
31
35
|
|
|
32
36
|
```tsx
|
|
33
|
-
import { useUser,
|
|
37
|
+
import { useUser, useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
|
|
34
38
|
|
|
35
39
|
function MyComponent() {
|
|
36
|
-
const user = useUser();
|
|
37
|
-
const walletAccounts =
|
|
40
|
+
const { data: user } = useUser();
|
|
41
|
+
const { data: walletAccounts } = useGetWalletAccounts();
|
|
38
42
|
|
|
39
43
|
return (
|
|
40
44
|
<div>
|
|
41
45
|
<p>User: {user?.email}</p>
|
|
42
|
-
<p>Wallets: {walletAccounts
|
|
46
|
+
<p>Wallets: {walletAccounts?.length ?? 0}</p>
|
|
43
47
|
</div>
|
|
44
48
|
);
|
|
45
49
|
}
|
|
@@ -52,6 +56,6 @@ function MyComponent() {
|
|
|
52
56
|
| `useUser` | Current authenticated user |
|
|
53
57
|
| `useInitStatus` | Client initialization status |
|
|
54
58
|
| `useSessionExpiresAt` | Session expiration date |
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
59
|
+
| `useGetUserSocialAccounts` | User's linked social accounts |
|
|
60
|
+
| `useGetWalletAccounts` | Connected wallet accounts |
|
|
61
|
+
| `useGetAvailableWalletProvidersData` | Available wallet providers |
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ let _dynamic_labs_sdk_client_waas = require("@dynamic-labs-sdk/client/waas");
|
|
|
8
8
|
|
|
9
9
|
//#region package.json
|
|
10
10
|
var name = "@dynamic-labs-sdk/react-hooks";
|
|
11
|
-
var version = "1.19.
|
|
11
|
+
var version = "1.19.1";
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/modules/DynamicContext/DynamicContext.ts
|
package/dist/index.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import { backupWaasKeySharesToGoogleDrive, createWaasWalletAccounts, delegateWaa
|
|
|
8
8
|
|
|
9
9
|
//#region package.json
|
|
10
10
|
var name = "@dynamic-labs-sdk/react-hooks";
|
|
11
|
-
var version = "1.19.
|
|
11
|
+
var version = "1.19.1";
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/modules/DynamicContext/DynamicContext.ts
|