@t8/react-pending 1.0.20 → 1.0.22
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/dist/index.js +2 -7
- package/index.ts +4 -4
- package/package.json +3 -3
- package/src/PendingStateContext.ts +1 -1
- package/src/PendingStateProvider.tsx +2 -2
- package/src/usePendingState.ts +2 -2
- package/tsconfig.json +6 -3
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/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./src/PendingState";
|
|
2
|
-
export * from "./src/PendingStateContext";
|
|
3
|
-
export * from "./src/PendingStateProvider";
|
|
4
|
-
export * from "./src/usePendingState";
|
|
1
|
+
export * from "./src/PendingState.ts";
|
|
2
|
+
export * from "./src/PendingStateContext.ts";
|
|
3
|
+
export * from "./src/PendingStateProvider.tsx";
|
|
4
|
+
export * from "./src/usePendingState.ts";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/react-pending",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Concise async action state tracking for React apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@playwright/test": "^1.56.0",
|
|
35
|
-
"@t8/serve": "^0.1.
|
|
35
|
+
"@t8/serve": "^0.1.34",
|
|
36
36
|
"@types/node": "^24.5.2",
|
|
37
37
|
"@types/react": "^19.1.10",
|
|
38
38
|
"@types/react-dom": "^19.1.9",
|
|
@@ -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.33"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Store } from "@t8/react-store";
|
|
2
2
|
import { createContext } from "react";
|
|
3
|
-
import type { PendingState } from "./PendingState";
|
|
3
|
+
import type { PendingState } from "./PendingState.ts";
|
|
4
4
|
|
|
5
5
|
export const PendingStateContext = createContext(
|
|
6
6
|
new Map<string, Store<PendingState>>(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Store } from "@t8/react-store";
|
|
2
2
|
import { type ReactNode, useMemo, useRef } from "react";
|
|
3
|
-
import type { PendingState } from "./PendingState";
|
|
4
|
-
import { PendingStateContext } from "./PendingStateContext";
|
|
3
|
+
import type { PendingState } from "./PendingState.ts";
|
|
4
|
+
import { PendingStateContext } from "./PendingStateContext.ts";
|
|
5
5
|
|
|
6
6
|
export type PendingStateProviderProps = {
|
|
7
7
|
value?:
|
package/src/usePendingState.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isStore, type SetStoreState, Store, useStore } from "@t8/react-store";
|
|
2
2
|
import { useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
3
|
-
import type { PendingState } from "./PendingState";
|
|
4
|
-
import { PendingStateContext } from "./PendingStateContext";
|
|
3
|
+
import type { PendingState } from "./PendingState.ts";
|
|
4
|
+
import { PendingStateContext } from "./PendingStateContext.ts";
|
|
5
5
|
|
|
6
6
|
function createState(
|
|
7
7
|
initialized = false,
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": ["index.ts", "playwright.config.ts", "src", "tests"],
|
|
2
|
+
"include": ["./index.ts", "./playwright.config.ts", "./src", "./tests"],
|
|
3
3
|
"compilerOptions": {
|
|
4
|
+
"noEmit": true,
|
|
4
5
|
"lib": ["ESNext", "DOM"],
|
|
5
|
-
"target": "
|
|
6
|
+
"target": "esnext",
|
|
6
7
|
"outDir": "dist",
|
|
7
|
-
"
|
|
8
|
+
"module": "nodenext",
|
|
9
|
+
"moduleResolution": "nodenext",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
8
11
|
"jsx": "react-jsx",
|
|
9
12
|
"strict": true,
|
|
10
13
|
"noUnusedLocals": true,
|