@t8/react-pending 1.0.18 → 1.0.20
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 +5 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -58,7 +58,9 @@ Objective: Track the pending state of the asynchronous action `fetchItems()` to
|
|
|
58
58
|
|
|
59
59
|
[Live demo](https://codesandbox.io/p/sandbox/rrr9cl?file=%2Fsrc%2FItemList.tsx)
|
|
60
60
|
|
|
61
|
-
🔹
|
|
61
|
+
🔹 To share the async action's pending state with multiple components we're using the string key parameter of `usePendingState(stateKey)`. This key can be used with `usePendingState(stateKey)` in other components to refer to the same pending state (as in the `Status` component above), so `stateKey` should be unique to the particular pending state.
|
|
62
|
+
|
|
63
|
+
🔹 In the example above, the data returned from the async action is stored in the component's local state, but it can be stored in any app state of the developer's choice without affecting how the `usePendingState()` hook is used.
|
|
62
64
|
|
|
63
65
|
## Local pending state
|
|
64
66
|
|
|
@@ -96,7 +98,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
|
|
|
96
98
|
|
|
97
99
|
🔹 This option allows the async action to reject explicitly, along with exposing `state.error` that goes by default.
|
|
98
100
|
|
|
99
|
-
## Providing blank initial pending
|
|
101
|
+
## Providing blank initial pending state
|
|
100
102
|
|
|
101
103
|
```diff
|
|
102
104
|
+ import { PendingStateProvider } from "@t8/react-pending";
|
|
@@ -109,7 +111,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
|
|
|
109
111
|
|
|
110
112
|
🔹 `<PendingStateProvider>` creates an isolated instance of initial shared action state. Prime use cases: tests, SSR. It isn't required with client-side rendering, but it can be used to separate action states of larger self-contained portions of a web app.
|
|
111
113
|
|
|
112
|
-
## Providing custom initial pending
|
|
114
|
+
## Providing custom initial pending state
|
|
113
115
|
|
|
114
116
|
```diff
|
|
115
117
|
+ let initialState = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/react-pending",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "Concise async action state tracking for React apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"typescript": "^5.9.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@t8/react-store": "^1.0.
|
|
43
|
+
"@t8/react-store": "^1.0.30"
|
|
44
44
|
}
|
|
45
45
|
}
|