@faasjs/react 0.0.5-beta.4 → 0.0.5-beta.5

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.
Files changed (2) hide show
  1. package/README.md +41 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -47,6 +47,7 @@ React plugin for FaasJS.
47
47
  - [getClient](#getclient)
48
48
  - [signal](#signal)
49
49
  - [useFaas](#usefaas)
50
+ - [useSignalState](#usesignalstate)
50
51
 
51
52
  ## Type Aliases
52
53
 
@@ -413,3 +414,43 @@ function Post ({ id }) {
413
414
  return <h1>{data.title}</h1>
414
415
  }
415
416
  ```
417
+
418
+ ___
419
+
420
+ ### useSignalState
421
+
422
+ ▸ **useSignalState**\<`T`\>(`initialValue`, `options?`): readonly [`T`, (`changes`: `SetStateAction`\<`T`\>) => `void`]
423
+
424
+ Create a [signal](https://preactjs.com/guide/v10/signals) like useState.
425
+
426
+ ```tsx
427
+ import { useSignalState, useSignalEffect } from '@faasjs/react'
428
+
429
+ function App () {
430
+ const [count, setCount] = useSignalState(0, { debugName: 'count' })
431
+
432
+ useSignalEffect(() => console.log('count', count))
433
+
434
+ return <div>
435
+ <button onClick={() => setCount(count + 1)}>+</button>
436
+ <span>{count}</span>
437
+ </div>
438
+ }
439
+ ```
440
+
441
+ #### Type parameters
442
+
443
+ | Name | Type |
444
+ | :------ | :------ |
445
+ | `T` | `any` |
446
+
447
+ #### Parameters
448
+
449
+ | Name | Type |
450
+ | :------ | :------ |
451
+ | `initialValue` | `T` |
452
+ | `options` | [`SignalOptions`](#signaloptions) |
453
+
454
+ #### Returns
455
+
456
+ readonly [`T`, (`changes`: `SetStateAction`\<`T`\>) => `void`]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "0.0.5-beta.4",
3
+ "version": "0.0.5-beta.5",
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": "0.0.5-beta.4"
25
+ "@faasjs/browser": "0.0.5-beta.5"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "*",