@pdg/react-hook 1.0.40 → 1.0.41

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @pdg/react-hook
2
2
 
3
- Admin Layout for React
3
+ Typescript React Hook Module
4
4
 
5
5
  ## 설치
6
6
  ```
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
- export {};
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
- "version": "1.0.40",
5
- "description": "React Hook",
3
+ "title": "Typescript React Hook Module",
4
+ "description": "Typescript React Hook Module",
5
+ "version": "1.0.41",
6
6
  "type": "module",
7
- "types": "dist/index.d.ts",
8
- "main": "dist/index.js",
9
- "module": "dist/index.esm.js",
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,55 @@
22
29
  ],
23
30
  "scripts": {
24
31
  "dev": "cd examples && npm run dev",
25
- "dev-prd-lib": "cd examples && npm run dev-prd-lib",
26
- "build": "rollup -c --bundleConfigAsCjs",
27
- "pub": "npm i && npm run build && npm publish --access=public && rm ./.git/hooks/pre-commit",
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
- "react",
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"
47
56
  },
48
57
  "devDependencies": {
49
- "@eslint/js": "^9.28.0",
50
- "@pdg/types": "^1.0.8",
51
- "@rollup/plugin-commonjs": "^28.0.3",
52
- "@rollup/plugin-eslint": "^9.0.5",
53
- "@rollup/plugin-node-resolve": "^16.0.1",
54
- "@types/node": "^22.15.29",
55
- "@types/react": "^19.1.6",
56
- "@typescript-eslint/parser": "^8.33.0",
57
- "eslint": "9.28.0",
58
- "eslint-config-prettier": "^10.1.5",
59
- "eslint-plugin-prettier": "^5.4.1",
60
- "eslint-plugin-react": "^7.37.5",
61
- "eslint-plugin-react-hooks": "^5.2.0",
62
- "prettier": "^3.5.3",
63
- "rollup": "^4.41.1",
64
- "rollup-plugin-delete": "^2.2.0",
65
- "rollup-plugin-peer-deps-external": "^2.2.4",
66
- "rollup-plugin-sass": "^1.15.2",
67
- "rollup-plugin-typescript2": "^0.36.0",
68
- "sass": "^1.89.1",
69
- "typescript": "^5.8.3",
70
- "typescript-eslint": "^8.33.0"
58
+ "@eslint/js": "9.39.1",
59
+ "@pdg/types": "1.0.9",
60
+ "@rollup/plugin-commonjs": "29.0.0",
61
+ "@rollup/plugin-node-resolve": "16.0.3",
62
+ "@types/node": "^22.19.2",
63
+ "@types/react": "19.2.7",
64
+ "@typescript-eslint/parser": "8.49.0",
65
+ "eslint": "9.39.1",
66
+ "eslint-config-prettier": "10.1.8",
67
+ "eslint-plugin-prettier": "5.5.4",
68
+ "eslint-plugin-react": "7.37.5",
69
+ "eslint-plugin-react-hooks": "5.2.0",
70
+ "eslint-plugin-react-refresh": "0.4.24",
71
+ "globals": "^16.5.0",
72
+ "prettier": "3.7.4",
73
+ "rollup": "4.53.3",
74
+ "rollup-plugin-delete": "2.2.0",
75
+ "rollup-plugin-peer-deps-external": "2.2.4",
76
+ "rollup-plugin-sass": "1.15.3",
77
+ "rollup-plugin-typescript2": "0.36.0",
78
+ "sass": "1.95.1",
79
+ "ts-node": "10.9.2",
80
+ "typescript": "5.9.3",
81
+ "typescript-eslint": "8.49.0"
71
82
  }
72
83
  }