@faasjs/react 1.4.1 → 1.5.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 +25 -444
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# @faasjs/react
|
|
2
2
|
|
|
3
|
-
[](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/react/LICENSE)
|
|
4
|
-
[](https://www.npmjs.com/package/@faasjs/react)
|
|
5
|
-
[](https://www.npmjs.com/package/@faasjs/react)
|
|
6
|
-
|
|
7
3
|
React plugin for FaasJS.
|
|
8
4
|
|
|
5
|
+
[](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/react/LICENSE)
|
|
6
|
+
[](https://www.npmjs.com/package/@faasjs/react)
|
|
7
|
+
|
|
9
8
|
**If you use [SWR](https://swr.vercel.app) or [React Query / TanStack Query](https://tanstack.com/query), please use [`@faasjs/browser`](https://faasjs.com/doc/browser) directly.**
|
|
10
9
|
|
|
11
10
|
## Install
|
|
@@ -25,6 +24,7 @@ const client = FaasReactClient({
|
|
|
25
24
|
domain: 'localhost:8080/api'
|
|
26
25
|
})
|
|
27
26
|
```
|
|
27
|
+
|
|
28
28
|
2. Use [faas](#faas), [useFaas](#usefaas) or [FaasDataWrapper](#faasdatawrapper).
|
|
29
29
|
|
|
30
30
|
## Usage with [@preact/signal-react](https://github.com/preactjs/signals/blob/main/packages/react/README.md)
|
|
@@ -38,456 +38,37 @@ const client = FaasReactClient({
|
|
|
38
38
|
```
|
|
39
39
|
3. Add `import '@preact/signals-react/auto'` to your test files.
|
|
40
40
|
|
|
41
|
-
##
|
|
42
|
-
|
|
43
|
-
### Classes
|
|
41
|
+
## Classes
|
|
44
42
|
|
|
45
43
|
- [ErrorBoundary](classes/ErrorBoundary.md)
|
|
46
44
|
- [Response](classes/Response.md)
|
|
47
45
|
- [ResponseError](classes/ResponseError.md)
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
## Interfaces
|
|
50
48
|
|
|
51
49
|
- [ErrorBoundaryProps](interfaces/ErrorBoundaryProps.md)
|
|
52
50
|
|
|
53
|
-
### Type Aliases
|
|
54
|
-
|
|
55
|
-
- [ErrorChildrenProps](#errorchildrenprops)
|
|
56
|
-
- [FaasAction](#faasaction)
|
|
57
|
-
- [FaasData](#faasdata)
|
|
58
|
-
- [FaasDataInjection](#faasdatainjection)
|
|
59
|
-
- [FaasDataWrapperProps](#faasdatawrapperprops)
|
|
60
|
-
- [FaasParams](#faasparams)
|
|
61
|
-
- [FaasReactClientInstance](#faasreactclientinstance)
|
|
62
|
-
- [FaasReactClientOptions](#faasreactclientoptions)
|
|
63
|
-
- [Options](#options)
|
|
64
|
-
- [ResponseHeaders](#responseheaders)
|
|
65
|
-
- [SignalOptions](#signaloptions)
|
|
66
|
-
- [useFaasOptions](#usefaasoptions)
|
|
67
|
-
|
|
68
|
-
### Functions
|
|
69
|
-
|
|
70
|
-
- [FaasDataWrapper](#faasdatawrapper)
|
|
71
|
-
- [FaasReactClient](#faasreactclient)
|
|
72
|
-
- [faas](#faas)
|
|
73
|
-
- [getClient](#getclient)
|
|
74
|
-
- [signal](#signal)
|
|
75
|
-
- [useFaas](#usefaas)
|
|
76
|
-
- [useSignalState](#usesignalstate)
|
|
77
|
-
|
|
78
51
|
## Type Aliases
|
|
79
52
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
___
|
|
94
|
-
|
|
95
|
-
### FaasAction
|
|
96
|
-
|
|
97
|
-
Ƭ **FaasAction**: `FaasActionPaths` \| `Record`\<`string`, `any`\>
|
|
98
|
-
|
|
99
|
-
___
|
|
100
|
-
|
|
101
|
-
### FaasData
|
|
102
|
-
|
|
103
|
-
Ƭ **FaasData**\<`T`\>: `T` extends `FaasActionPaths` ? `FaasActions`[`T`][``"Data"``] : `T`
|
|
104
|
-
|
|
105
|
-
#### Type parameters
|
|
106
|
-
|
|
107
|
-
| Name | Type |
|
|
108
|
-
| :------ | :------ |
|
|
109
|
-
| `T` | `any` |
|
|
110
|
-
|
|
111
|
-
___
|
|
112
|
-
|
|
113
|
-
### FaasDataInjection
|
|
114
|
-
|
|
115
|
-
Ƭ **FaasDataInjection**\<`Data`\>: `Object`
|
|
116
|
-
|
|
117
|
-
Injects FaasData props.
|
|
118
|
-
|
|
119
|
-
#### Type parameters
|
|
120
|
-
|
|
121
|
-
| Name | Type |
|
|
122
|
-
| :------ | :------ |
|
|
123
|
-
| `Data` | `any` |
|
|
124
|
-
|
|
125
|
-
#### Type declaration
|
|
126
|
-
|
|
127
|
-
| Name | Type |
|
|
128
|
-
| :------ | :------ |
|
|
129
|
-
| `action` | `string` \| `any` |
|
|
130
|
-
| `data` | `Data` |
|
|
131
|
-
| `error` | `any` |
|
|
132
|
-
| `loading` | `boolean` |
|
|
133
|
-
| `params` | `Record`\<`string`, `any`\> |
|
|
134
|
-
| `promise` | `Promise`\<`Response`\<`Data`\>\> |
|
|
135
|
-
| `reloadTimes` | `number` |
|
|
136
|
-
| `setData` | `React.Dispatch`\<`React.SetStateAction`\<`Data`\>\> |
|
|
137
|
-
| `setError` | `React.Dispatch`\<`React.SetStateAction`\<`any`\>\> |
|
|
138
|
-
| `setLoading` | `React.Dispatch`\<`React.SetStateAction`\<`boolean`\>\> |
|
|
139
|
-
| `setPromise` | `React.Dispatch`\<`React.SetStateAction`\<`Promise`\<`Response`\<`Data`\>\>\>\> |
|
|
140
|
-
| `reload` | (`params?`: `Record`\<`string`, `any`\>) => `Promise`\<`any`\> |
|
|
141
|
-
|
|
142
|
-
___
|
|
143
|
-
|
|
144
|
-
### FaasDataWrapperProps
|
|
145
|
-
|
|
146
|
-
Ƭ **FaasDataWrapperProps**\<`PathOrData`\>: `Object`
|
|
147
|
-
|
|
148
|
-
#### Type parameters
|
|
149
|
-
|
|
150
|
-
| Name | Type |
|
|
151
|
-
| :------ | :------ |
|
|
152
|
-
| `PathOrData` | extends `FaasAction` |
|
|
153
|
-
|
|
154
|
-
#### Type declaration
|
|
155
|
-
|
|
156
|
-
| Name | Type | Description |
|
|
157
|
-
| :------ | :------ | :------ |
|
|
158
|
-
| `action` | `string` | - |
|
|
159
|
-
| `children?` | `React.ReactElement`\<`Partial`\<[`FaasDataInjection`](#faasdatainjection)\>\> | - |
|
|
160
|
-
| `data?` | `FaasData`\<`PathOrData`\> | use custom data, should work with setData |
|
|
161
|
-
| `fallback?` | `JSX.Element` \| ``false`` | - |
|
|
162
|
-
| `params?` | `FaasParams`\<`PathOrData`\> | - |
|
|
163
|
-
| `setData?` | `React.Dispatch`\<`React.SetStateAction`\<`FaasData`\<`PathOrData`\>\>\> | use custom setData, should work with data |
|
|
164
|
-
| `onDataChange?` | (`args`: [`FaasDataInjection`](#faasdatainjection)\<`FaasData`\<`PathOrData`\>\>) => `void` | - |
|
|
165
|
-
| `render?` | (`args`: [`FaasDataInjection`](#faasdatainjection)\<`FaasData`\<`PathOrData`\>\>) => `Element` \| `Element`[] | - |
|
|
166
|
-
|
|
167
|
-
___
|
|
168
|
-
|
|
169
|
-
### FaasParams
|
|
170
|
-
|
|
171
|
-
Ƭ **FaasParams**\<`T`\>: `T` extends `FaasActionPaths` ? `FaasActions`[`T`][``"Params"``] : `any`
|
|
172
|
-
|
|
173
|
-
#### Type parameters
|
|
174
|
-
|
|
175
|
-
| Name | Type |
|
|
176
|
-
| :------ | :------ |
|
|
177
|
-
| `T` | `any` |
|
|
178
|
-
|
|
179
|
-
___
|
|
180
|
-
|
|
181
|
-
### FaasReactClientInstance
|
|
182
|
-
|
|
183
|
-
Ƭ **FaasReactClientInstance**: `Object`
|
|
184
|
-
|
|
185
|
-
#### Type declaration
|
|
186
|
-
|
|
187
|
-
| Name | Type |
|
|
188
|
-
| :------ | :------ |
|
|
189
|
-
| `faas` | \<PathOrData\>(`action`: `string` \| `PathOrData`, `params`: `FaasParams`\<`PathOrData`\>) => `Promise`\<`Response`\<`FaasData`\<`PathOrData`\>\>\> |
|
|
190
|
-
| `id` | `string` |
|
|
191
|
-
| `useFaas` | \<PathOrData\>(`action`: `string` \| `PathOrData`, `defaultParams`: `FaasParams`\<`PathOrData`\>, `options?`: [`useFaasOptions`](#usefaasoptions)\<`PathOrData`\>) => [`FaasDataInjection`](#faasdatainjection)\<`FaasData`\<`PathOrData`\>\> |
|
|
192
|
-
| `FaasDataWrapper` | \<PathOrData\>(`props`: [`FaasDataWrapperProps`](#faasdatawrapperprops)\<`PathOrData`\>) => `Element` |
|
|
193
|
-
|
|
194
|
-
___
|
|
195
|
-
|
|
196
|
-
### FaasReactClientOptions
|
|
197
|
-
|
|
198
|
-
Ƭ **FaasReactClientOptions**: `Object`
|
|
199
|
-
|
|
200
|
-
#### Type declaration
|
|
201
|
-
|
|
202
|
-
| Name | Type |
|
|
203
|
-
| :------ | :------ |
|
|
204
|
-
| `domain` | `string` |
|
|
205
|
-
| `onError?` | (`action`: `string`, `params`: `Record`\<`string`, `any`\>) => (`res`: [`ResponseError`](classes/ResponseError.md)) => `Promise`\<`void`\> |
|
|
206
|
-
| `options?` | [`Options`](#options) |
|
|
207
|
-
|
|
208
|
-
___
|
|
209
|
-
|
|
210
|
-
### Options
|
|
211
|
-
|
|
212
|
-
Ƭ **Options**: `RequestInit` & \{ `beforeRequest?`: (`{
|
|
213
|
-
action,
|
|
214
|
-
params,
|
|
215
|
-
options,
|
|
216
|
-
headers,
|
|
217
|
-
}`: \{ `action`: `string` ; `headers`: `Record`\<`string`, `string`\> ; `options`: [`Options`](#options) ; `params`: `Record`\<`string`, `any`\> }) => `Promise`\<`void`\> ; `headers?`: `Record`\<`string`, `string`\> ; `request?`: \<PathOrData\>(`url`: `string`, `options`: [`Options`](#options)) => `Promise`\<[`Response`](classes/Response.md)\<[`FaasData`](#faasdata)\<`PathOrData`\>\>\> }
|
|
218
|
-
|
|
219
|
-
___
|
|
220
|
-
|
|
221
|
-
### ResponseHeaders
|
|
222
|
-
|
|
223
|
-
Ƭ **ResponseHeaders**: `Object`
|
|
224
|
-
|
|
225
|
-
#### Index signature
|
|
226
|
-
|
|
227
|
-
▪ [key: `string`]: `string`
|
|
228
|
-
|
|
229
|
-
___
|
|
230
|
-
|
|
231
|
-
### SignalOptions
|
|
232
|
-
|
|
233
|
-
Ƭ **SignalOptions**: `Object`
|
|
234
|
-
|
|
235
|
-
#### Type declaration
|
|
236
|
-
|
|
237
|
-
| Name | Type |
|
|
238
|
-
| :------ | :------ |
|
|
239
|
-
| `debugName?` | `string` |
|
|
240
|
-
|
|
241
|
-
___
|
|
242
|
-
|
|
243
|
-
### useFaasOptions
|
|
244
|
-
|
|
245
|
-
Ƭ **useFaasOptions**\<`PathOrData`\>: `Object`
|
|
246
|
-
|
|
247
|
-
#### Type parameters
|
|
248
|
-
|
|
249
|
-
| Name | Type |
|
|
250
|
-
| :------ | :------ |
|
|
251
|
-
| `PathOrData` | extends `FaasAction` |
|
|
252
|
-
|
|
253
|
-
#### Type declaration
|
|
254
|
-
|
|
255
|
-
| Name | Type | Description |
|
|
256
|
-
| :------ | :------ | :------ |
|
|
257
|
-
| `data?` | `FaasData`\<`PathOrData`\> | - |
|
|
258
|
-
| `debounce?` | `number` | send the last request after milliseconds |
|
|
259
|
-
| `params?` | `FaasParams`\<`PathOrData`\> | - |
|
|
260
|
-
| `setData?` | `React.Dispatch`\<`React.SetStateAction`\<`FaasData`\<`PathOrData`\>\>\> | - |
|
|
261
|
-
| `skip?` | `boolean` \| (`params`: `FaasParams`\<`PathOrData`\>) => `boolean` | if skip is true, will not send request |
|
|
53
|
+
- [ErrorChildrenProps](type-aliases/ErrorChildrenProps.md)
|
|
54
|
+
- [FaasAction](type-aliases/FaasAction.md)
|
|
55
|
+
- [FaasData](type-aliases/FaasData.md)
|
|
56
|
+
- [FaasDataInjection](type-aliases/FaasDataInjection.md)
|
|
57
|
+
- [FaasDataWrapperProps](type-aliases/FaasDataWrapperProps.md)
|
|
58
|
+
- [FaasParams](type-aliases/FaasParams.md)
|
|
59
|
+
- [FaasReactClientInstance](type-aliases/FaasReactClientInstance.md)
|
|
60
|
+
- [FaasReactClientOptions](type-aliases/FaasReactClientOptions.md)
|
|
61
|
+
- [Options](type-aliases/Options.md)
|
|
62
|
+
- [ResponseHeaders](type-aliases/ResponseHeaders.md)
|
|
63
|
+
- [SignalOptions](type-aliases/SignalOptions.md)
|
|
64
|
+
- [useFaasOptions](type-aliases/useFaasOptions.md)
|
|
262
65
|
|
|
263
66
|
## Functions
|
|
264
67
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
| Name | Type |
|
|
274
|
-
| :------ | :------ |
|
|
275
|
-
| `PathOrData` | extends `Record`\<`string`, `any`\> |
|
|
276
|
-
|
|
277
|
-
#### Parameters
|
|
278
|
-
|
|
279
|
-
| Name | Type |
|
|
280
|
-
| :------ | :------ |
|
|
281
|
-
| `props` | [`FaasDataWrapperProps`](#faasdatawrapperprops)\<`PathOrData`\> |
|
|
282
|
-
|
|
283
|
-
#### Returns
|
|
284
|
-
|
|
285
|
-
`JSX.Element`
|
|
286
|
-
|
|
287
|
-
**`Example`**
|
|
288
|
-
|
|
289
|
-
```tsx
|
|
290
|
-
<FaasDataWrapper<{
|
|
291
|
-
id: string
|
|
292
|
-
title: string
|
|
293
|
-
}>
|
|
294
|
-
action='post/get'
|
|
295
|
-
params={ { id: 1 } }
|
|
296
|
-
render={ ({ data }) => <h1>{ data.title }</h1> }
|
|
297
|
-
/>
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
___
|
|
301
|
-
|
|
302
|
-
### FaasReactClient
|
|
303
|
-
|
|
304
|
-
▸ **FaasReactClient**(`«destructured»`): [`FaasReactClientInstance`](#faasreactclientinstance)
|
|
305
|
-
|
|
306
|
-
Before use faas, you should initialize a FaasReactClient.
|
|
307
|
-
|
|
308
|
-
#### Parameters
|
|
309
|
-
|
|
310
|
-
| Name | Type |
|
|
311
|
-
| :------ | :------ |
|
|
312
|
-
| `«destructured»` | [`FaasReactClientOptions`](#faasreactclientoptions) |
|
|
313
|
-
|
|
314
|
-
#### Returns
|
|
315
|
-
|
|
316
|
-
[`FaasReactClientInstance`](#faasreactclientinstance)
|
|
317
|
-
|
|
318
|
-
**`Example`**
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
const client = FaasReactClient({
|
|
322
|
-
domain: 'localhost:8080/api'
|
|
323
|
-
})
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
___
|
|
327
|
-
|
|
328
|
-
### faas
|
|
329
|
-
|
|
330
|
-
▸ **faas**\<`PathOrData`\>(`action`, `params`): `Promise`\<[`Response`](classes/Response.md)\<[`FaasData`](#faasdata)\<`PathOrData`\>\>\>
|
|
331
|
-
|
|
332
|
-
Request faas server
|
|
333
|
-
|
|
334
|
-
#### Type parameters
|
|
335
|
-
|
|
336
|
-
| Name | Type |
|
|
337
|
-
| :------ | :------ |
|
|
338
|
-
| `PathOrData` | extends `Record`\<`string`, `any`\> |
|
|
339
|
-
|
|
340
|
-
#### Parameters
|
|
341
|
-
|
|
342
|
-
| Name | Type | Description |
|
|
343
|
-
| :------ | :------ | :------ |
|
|
344
|
-
| `action` | `string` \| `PathOrData` | {string} action name |
|
|
345
|
-
| `params` | [`FaasParams`](#faasparams)\<`PathOrData`\> | {object} action params |
|
|
346
|
-
|
|
347
|
-
#### Returns
|
|
348
|
-
|
|
349
|
-
`Promise`\<[`Response`](classes/Response.md)\<[`FaasData`](#faasdata)\<`PathOrData`\>\>\>
|
|
350
|
-
|
|
351
|
-
**`Example`**
|
|
352
|
-
|
|
353
|
-
```ts
|
|
354
|
-
faas<{ title: string }>('post/get', { id: 1 }).then(res => {
|
|
355
|
-
console.log(res.data.title)
|
|
356
|
-
})
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
___
|
|
360
|
-
|
|
361
|
-
### getClient
|
|
362
|
-
|
|
363
|
-
▸ **getClient**(`domain?`): [`FaasReactClientInstance`](#faasreactclientinstance)
|
|
364
|
-
|
|
365
|
-
Get FaasReactClient instance
|
|
366
|
-
|
|
367
|
-
#### Parameters
|
|
368
|
-
|
|
369
|
-
| Name | Type | Description |
|
|
370
|
-
| :------ | :------ | :------ |
|
|
371
|
-
| `domain?` | `string` | {string} empty string for default domain |
|
|
372
|
-
|
|
373
|
-
#### Returns
|
|
374
|
-
|
|
375
|
-
[`FaasReactClientInstance`](#faasreactclientinstance)
|
|
376
|
-
|
|
377
|
-
**`Example`**
|
|
378
|
-
|
|
379
|
-
```ts
|
|
380
|
-
getClient()
|
|
381
|
-
// or
|
|
382
|
-
getClient('another-domain')
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
___
|
|
386
|
-
|
|
387
|
-
### signal
|
|
388
|
-
|
|
389
|
-
▸ **signal**\<`T`\>(`initialValue`, `options?`): `Signal`\<`T`\>
|
|
390
|
-
|
|
391
|
-
Create a [signal](https://preactjs.com/guide/v10/signals) with options
|
|
392
|
-
|
|
393
|
-
#### Type parameters
|
|
394
|
-
|
|
395
|
-
| Name | Type |
|
|
396
|
-
| :------ | :------ |
|
|
397
|
-
| `T` | `any` |
|
|
398
|
-
|
|
399
|
-
#### Parameters
|
|
400
|
-
|
|
401
|
-
| Name | Type |
|
|
402
|
-
| :------ | :------ |
|
|
403
|
-
| `initialValue` | `any` |
|
|
404
|
-
| `options` | [`SignalOptions`](#signaloptions) |
|
|
405
|
-
|
|
406
|
-
#### Returns
|
|
407
|
-
|
|
408
|
-
`Signal`\<`T`\>
|
|
409
|
-
|
|
410
|
-
**`Example`**
|
|
411
|
-
|
|
412
|
-
```ts
|
|
413
|
-
import { signal } from '@faasjs/react'
|
|
414
|
-
|
|
415
|
-
const count = signal(0, { debugName: 'count' })
|
|
416
|
-
|
|
417
|
-
count.value = 1
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
___
|
|
421
|
-
|
|
422
|
-
### useFaas
|
|
423
|
-
|
|
424
|
-
▸ **useFaas**\<`PathOrData`\>(`action`, `defaultParams`, `options?`): [`FaasDataInjection`](#faasdatainjection)\<[`FaasData`](#faasdata)\<`PathOrData`\>\>
|
|
425
|
-
|
|
426
|
-
Request faas server with React hook
|
|
427
|
-
|
|
428
|
-
#### Type parameters
|
|
429
|
-
|
|
430
|
-
| Name | Type |
|
|
431
|
-
| :------ | :------ |
|
|
432
|
-
| `PathOrData` | extends `Record`\<`string`, `any`\> |
|
|
433
|
-
|
|
434
|
-
#### Parameters
|
|
435
|
-
|
|
436
|
-
| Name | Type | Description |
|
|
437
|
-
| :------ | :------ | :------ |
|
|
438
|
-
| `action` | `string` \| `PathOrData` | {string} action name |
|
|
439
|
-
| `defaultParams` | [`FaasParams`](#faasparams)\<`PathOrData`\> | {object} initial action params |
|
|
440
|
-
| `options?` | [`useFaasOptions`](#usefaasoptions)\<`PathOrData`\> | - |
|
|
441
|
-
|
|
442
|
-
#### Returns
|
|
443
|
-
|
|
444
|
-
[`FaasDataInjection`](#faasdatainjection)\<[`FaasData`](#faasdata)\<`PathOrData`\>\>
|
|
445
|
-
|
|
446
|
-
**`Example`**
|
|
447
|
-
|
|
448
|
-
```tsx
|
|
449
|
-
function Post ({ id }) {
|
|
450
|
-
const { data } = useFaas<{ title: string }>('post/get', { id })
|
|
451
|
-
return <h1>{data.title}</h1>
|
|
452
|
-
}
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
___
|
|
456
|
-
|
|
457
|
-
### useSignalState
|
|
458
|
-
|
|
459
|
-
▸ **useSignalState**\<`T`\>(`initialValue`, `options?`): readonly [`T`, (`changes`: `SetStateAction`\<`T`\>) => `void`]
|
|
460
|
-
|
|
461
|
-
Create a [signal](https://preactjs.com/guide/v10/signals) like useState.
|
|
462
|
-
|
|
463
|
-
```tsx
|
|
464
|
-
import { useSignalState, useSignalEffect } from '@faasjs/react'
|
|
465
|
-
|
|
466
|
-
function App () {
|
|
467
|
-
const [count, setCount] = useSignalState(0, { debugName: 'count' })
|
|
468
|
-
|
|
469
|
-
useSignalEffect(() => console.log('count', count))
|
|
470
|
-
|
|
471
|
-
return <div>
|
|
472
|
-
<button onClick={() => setCount(count + 1)}>+</button>
|
|
473
|
-
<span>{count}</span>
|
|
474
|
-
</div>
|
|
475
|
-
}
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
#### Type parameters
|
|
479
|
-
|
|
480
|
-
| Name | Type |
|
|
481
|
-
| :------ | :------ |
|
|
482
|
-
| `T` | `any` |
|
|
483
|
-
|
|
484
|
-
#### Parameters
|
|
485
|
-
|
|
486
|
-
| Name | Type |
|
|
487
|
-
| :------ | :------ |
|
|
488
|
-
| `initialValue` | `T` |
|
|
489
|
-
| `options` | [`SignalOptions`](#signaloptions) |
|
|
490
|
-
|
|
491
|
-
#### Returns
|
|
492
|
-
|
|
493
|
-
readonly [`T`, (`changes`: `SetStateAction`\<`T`\>) => `void`]
|
|
68
|
+
- [FaasDataWrapper](functions/FaasDataWrapper.md)
|
|
69
|
+
- [FaasReactClient](functions/FaasReactClient.md)
|
|
70
|
+
- [faas](functions/faas.md)
|
|
71
|
+
- [getClient](functions/getClient.md)
|
|
72
|
+
- [signal](functions/signal.md)
|
|
73
|
+
- [useFaas](functions/useFaas.md)
|
|
74
|
+
- [useSignalState](functions/useSignalState.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@faasjs/browser": "1.
|
|
25
|
+
"@faasjs/browser": "1.5.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "*",
|