@pdg/react-hook 1.0.40 → 1.0.42
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 +1 -1
- package/dist/index.esm.js +11 -1
- package/dist/index.js +11 -1
- package/dist/state/useSafeState.d.ts +3 -1
- package/package.json +49 -36
package/README.md
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -257,6 +257,16 @@ function useAutoUpdateState(state, callback) {
|
|
|
257
257
|
}
|
|
258
258
|
}, []);
|
|
259
259
|
return [valueRef, _value, setValue];
|
|
260
|
+
}function useSafeState(initialState) {
|
|
261
|
+
const mountedRef = useMountedRef();
|
|
262
|
+
const [value, setValue] = useState(initialState);
|
|
263
|
+
const safeSetValue = useCallback((newValue) => {
|
|
264
|
+
if (mountedRef.current) {
|
|
265
|
+
setValue(newValue);
|
|
266
|
+
}
|
|
267
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
268
|
+
}, []);
|
|
269
|
+
return [value, safeSetValue];
|
|
260
270
|
}function useSafeUpdate() {
|
|
261
271
|
const mountedRef = useMountedRef();
|
|
262
272
|
return useCallback((callback) => {
|
|
@@ -265,4 +275,4 @@ function useAutoUpdateState(state, callback) {
|
|
|
265
275
|
}
|
|
266
276
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
267
277
|
}, []);
|
|
268
|
-
}export{clearIntervalRef,clearTimeoutRef,useAutoForceUpdate,useAutoUpdateLayoutRef,useAutoUpdateRef,useAutoUpdateRefState,useAutoUpdateState,useFirstSkipEffect,useFirstSkipLayoutEffect,useForceUpdate,useForwardLayoutRef,useForwardRef,useIntervalRef,useLayoutPerformance,useMountedRef,usePerformance,useRefState,useSafeUpdate,useTimeoutRef};
|
|
278
|
+
}export{clearIntervalRef,clearTimeoutRef,useAutoForceUpdate,useAutoUpdateLayoutRef,useAutoUpdateRef,useAutoUpdateRefState,useAutoUpdateState,useFirstSkipEffect,useFirstSkipLayoutEffect,useForceUpdate,useForwardLayoutRef,useForwardRef,useIntervalRef,useLayoutPerformance,useMountedRef,usePerformance,useRefState,useSafeState,useSafeUpdate,useTimeoutRef};
|
package/dist/index.js
CHANGED
|
@@ -257,6 +257,16 @@ function useAutoUpdateState(state, callback) {
|
|
|
257
257
|
}
|
|
258
258
|
}, []);
|
|
259
259
|
return [valueRef, _value, setValue];
|
|
260
|
+
}function useSafeState(initialState) {
|
|
261
|
+
const mountedRef = useMountedRef();
|
|
262
|
+
const [value, setValue] = react.useState(initialState);
|
|
263
|
+
const safeSetValue = react.useCallback((newValue) => {
|
|
264
|
+
if (mountedRef.current) {
|
|
265
|
+
setValue(newValue);
|
|
266
|
+
}
|
|
267
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
268
|
+
}, []);
|
|
269
|
+
return [value, safeSetValue];
|
|
260
270
|
}function useSafeUpdate() {
|
|
261
271
|
const mountedRef = useMountedRef();
|
|
262
272
|
return react.useCallback((callback) => {
|
|
@@ -265,4 +275,4 @@ function useAutoUpdateState(state, callback) {
|
|
|
265
275
|
}
|
|
266
276
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
267
277
|
}, []);
|
|
268
|
-
}exports.clearIntervalRef=clearIntervalRef;exports.clearTimeoutRef=clearTimeoutRef;exports.useAutoForceUpdate=useAutoForceUpdate;exports.useAutoUpdateLayoutRef=useAutoUpdateLayoutRef;exports.useAutoUpdateRef=useAutoUpdateRef;exports.useAutoUpdateRefState=useAutoUpdateRefState;exports.useAutoUpdateState=useAutoUpdateState;exports.useFirstSkipEffect=useFirstSkipEffect;exports.useFirstSkipLayoutEffect=useFirstSkipLayoutEffect;exports.useForceUpdate=useForceUpdate;exports.useForwardLayoutRef=useForwardLayoutRef;exports.useForwardRef=useForwardRef;exports.useIntervalRef=useIntervalRef;exports.useLayoutPerformance=useLayoutPerformance;exports.useMountedRef=useMountedRef;exports.usePerformance=usePerformance;exports.useRefState=useRefState;exports.useSafeUpdate=useSafeUpdate;exports.useTimeoutRef=useTimeoutRef;
|
|
278
|
+
}exports.clearIntervalRef=clearIntervalRef;exports.clearTimeoutRef=clearTimeoutRef;exports.useAutoForceUpdate=useAutoForceUpdate;exports.useAutoUpdateLayoutRef=useAutoUpdateLayoutRef;exports.useAutoUpdateRef=useAutoUpdateRef;exports.useAutoUpdateRefState=useAutoUpdateRefState;exports.useAutoUpdateState=useAutoUpdateState;exports.useFirstSkipEffect=useFirstSkipEffect;exports.useFirstSkipLayoutEffect=useFirstSkipLayoutEffect;exports.useForceUpdate=useForceUpdate;exports.useForwardLayoutRef=useForwardLayoutRef;exports.useForwardRef=useForwardRef;exports.useIntervalRef=useIntervalRef;exports.useLayoutPerformance=useLayoutPerformance;exports.useMountedRef=useMountedRef;exports.usePerformance=usePerformance;exports.useRefState=useRefState;exports.useSafeState=useSafeState;exports.useSafeUpdate=useSafeUpdate;exports.useTimeoutRef=useTimeoutRef;
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export declare function useSafeState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
|
|
3
|
+
export declare function useSafeState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
|
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdg/react-hook",
|
|
3
|
-
"title": "React Hook",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"title": "Typescript React Hook Module",
|
|
4
|
+
"description": "Typescript React Hook Module",
|
|
5
|
+
"version": "1.0.42",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.esm.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.esm.js",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
10
17
|
"repository": {
|
|
11
18
|
"type": "git",
|
|
12
19
|
"url": "git+https://github.com/parkdigy/react-hook.git",
|
|
@@ -22,51 +29,57 @@
|
|
|
22
29
|
],
|
|
23
30
|
"scripts": {
|
|
24
31
|
"dev": "cd examples && npm run dev",
|
|
25
|
-
"
|
|
26
|
-
"build": "
|
|
27
|
-
"
|
|
32
|
+
"watchman:del": "watchman watch-del \"${PWD}\" ; watchman watch-project \"${PWD}\"",
|
|
33
|
+
"build:examples": "cd examples && npm run build",
|
|
34
|
+
"build": "npm run watchman:del && npm run lint && rollup -c --bundleConfigAsCjs",
|
|
28
35
|
"git:commit": "node .git-commit.cjs",
|
|
29
36
|
"git:push": "git push",
|
|
30
37
|
"git:commit:push": "npm run git:commit && npm run git:push",
|
|
38
|
+
"git:merge:mirror": "node .git-merge.cjs mirror main",
|
|
31
39
|
"reset:gitignore": "git rm -r --cached . && git add .",
|
|
40
|
+
"pub": "npm i && npm run build:examples && npm run build && npm publish --access=public && rm ./.git/hooks/pre-commit",
|
|
41
|
+
"lint": "eslint './src/**/*.{ts,tsx}'",
|
|
32
42
|
"reinstall": "npm run reinstall:module",
|
|
33
|
-
"reinstall:module": "rm -rf node_modules && rm -f package-lock.json && npm i"
|
|
34
|
-
"lint": "eslint './src/**/*.{ts,tsx}'"
|
|
43
|
+
"reinstall:module": "rm -rf node_modules && rm -f package-lock.json && npm i"
|
|
35
44
|
},
|
|
36
45
|
"author": "YOUNG CHUL PARK",
|
|
37
46
|
"license": "MIT",
|
|
38
47
|
"readmeFilename": "README.md",
|
|
39
48
|
"keywords": [
|
|
40
|
-
"
|
|
41
|
-
"hook",
|
|
49
|
+
"util",
|
|
42
50
|
"typescript",
|
|
43
51
|
"javascript"
|
|
44
52
|
],
|
|
45
53
|
"peerDependencies": {
|
|
46
|
-
"react": ">=17.0.0"
|
|
54
|
+
"react": ">=17.0.0",
|
|
55
|
+
"react-dom": ">=17.0.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@pdg/types": "^1.0.9"
|
|
47
59
|
},
|
|
48
60
|
"devDependencies": {
|
|
49
|
-
"@eslint/js": "
|
|
50
|
-
"@
|
|
51
|
-
"@rollup/plugin-
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"eslint": "
|
|
58
|
-
"eslint-
|
|
59
|
-
"eslint-plugin-
|
|
60
|
-
"eslint-plugin-react": "
|
|
61
|
-
"
|
|
62
|
-
"prettier": "
|
|
63
|
-
"rollup": "
|
|
64
|
-
"rollup-plugin-delete": "
|
|
65
|
-
"rollup-plugin-peer-deps-external": "
|
|
66
|
-
"rollup-plugin-sass": "
|
|
67
|
-
"rollup-plugin-typescript2": "
|
|
68
|
-
"sass": "
|
|
69
|
-
"
|
|
70
|
-
"typescript
|
|
61
|
+
"@eslint/js": "9.39.1",
|
|
62
|
+
"@rollup/plugin-commonjs": "29.0.0",
|
|
63
|
+
"@rollup/plugin-node-resolve": "16.0.3",
|
|
64
|
+
"@types/node": "^22.19.2",
|
|
65
|
+
"@types/react": "19.2.7",
|
|
66
|
+
"@typescript-eslint/parser": "8.49.0",
|
|
67
|
+
"eslint": "9.39.1",
|
|
68
|
+
"eslint-config-prettier": "10.1.8",
|
|
69
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
70
|
+
"eslint-plugin-react": "7.37.5",
|
|
71
|
+
"eslint-plugin-react-hooks": "5.2.0",
|
|
72
|
+
"eslint-plugin-react-refresh": "0.4.24",
|
|
73
|
+
"globals": "^16.5.0",
|
|
74
|
+
"prettier": "3.7.4",
|
|
75
|
+
"rollup": "4.53.3",
|
|
76
|
+
"rollup-plugin-delete": "2.2.0",
|
|
77
|
+
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
78
|
+
"rollup-plugin-sass": "1.15.3",
|
|
79
|
+
"rollup-plugin-typescript2": "0.36.0",
|
|
80
|
+
"sass": "1.95.1",
|
|
81
|
+
"ts-node": "10.9.2",
|
|
82
|
+
"typescript": "5.9.3",
|
|
83
|
+
"typescript-eslint": "8.49.0"
|
|
71
84
|
}
|
|
72
85
|
}
|