@t8/react-pending 1.0.19 → 1.0.21
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 +2 -2
- package/dist/index.js +2 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
|
|
|
98
98
|
|
|
99
99
|
🔹 This option allows the async action to reject explicitly, along with exposing `state.error` that goes by default.
|
|
100
100
|
|
|
101
|
-
## Providing blank initial pending
|
|
101
|
+
## Providing blank initial pending state
|
|
102
102
|
|
|
103
103
|
```diff
|
|
104
104
|
+ import { PendingStateProvider } from "@t8/react-pending";
|
|
@@ -111,7 +111,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
|
|
|
111
111
|
|
|
112
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.
|
|
113
113
|
|
|
114
|
-
## Providing custom initial pending
|
|
114
|
+
## Providing custom initial pending state
|
|
115
115
|
|
|
116
116
|
```diff
|
|
117
117
|
+ let initialState = {
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,6 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
|
|
40
40
|
function useStore(store, shouldUpdate = true) {
|
|
41
41
|
if (!isStore(store)) throw new Error("'store' is not an instance of Store");
|
|
42
42
|
let [, setRevision] = useState(-1);
|
|
43
|
-
let initedRef = useRef(false);
|
|
44
43
|
let state = store.getState();
|
|
45
44
|
let setState = useMemo(() => store.setState.bind(store), [store]);
|
|
46
45
|
let initialStoreRevision = useRef(store.revision);
|
|
@@ -50,14 +49,10 @@ function useStore(store, shouldUpdate = true) {
|
|
|
50
49
|
if (typeof shouldUpdate !== "function" || shouldUpdate(nextState, prevState))
|
|
51
50
|
setRevision(Math.random());
|
|
52
51
|
});
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
if (store.revision !== initialStoreRevision.current)
|
|
56
|
-
setRevision(Math.random());
|
|
57
|
-
}
|
|
52
|
+
if (store.revision !== initialStoreRevision.current)
|
|
53
|
+
setRevision(Math.random());
|
|
58
54
|
return () => {
|
|
59
55
|
unsubscribe();
|
|
60
|
-
initedRef.current = false;
|
|
61
56
|
initialStoreRevision.current = store.revision;
|
|
62
57
|
};
|
|
63
58
|
}, [store, shouldUpdate]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/react-pending",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
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.31"
|
|
44
44
|
}
|
|
45
45
|
}
|