@reactuses/core 6.1.7 → 6.1.9

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
@@ -52,7 +52,9 @@ Refer to [documentations](https://reactuse.com/) for more details.
52
52
  ## Who's Using This
53
53
 
54
54
  [![PDD](https://img.shields.io/badge/PDD-E_Commerce-orange?style=for-the-badge)](https://www.pinduoduo.com/)
55
+ [![Shopee](https://img.shields.io/badge/Shopee-E_Commerce-red?style=for-the-badge)](https://shopee.com/)
55
56
  [![Ctrip](https://img.shields.io/badge/Ctrip-Travel-blue?style=for-the-badge)](https://www.ctrip.com/)
57
+ [![Bambu Lab](https://img.shields.io/badge/Bambu_Lab-3D_Printing-green?style=for-the-badge)](https://bambulab.com/)
56
58
 
57
59
  ---
58
60
 
package/dist/index.cjs CHANGED
@@ -2214,10 +2214,19 @@ const useMediaQuery = (query, defaultState)=>{
2214
2214
  function useRafState(initialState) {
2215
2215
  const frame = React.useRef(0);
2216
2216
  const [state, setState] = React.useState(initialState);
2217
+ const pendingUpdates = React.useRef([]);
2217
2218
  const setRafState = React.useCallback((value)=>{
2219
+ pendingUpdates.current.push(value);
2218
2220
  cancelAnimationFrame(frame.current);
2219
2221
  frame.current = requestAnimationFrame(()=>{
2220
- setState(value);
2222
+ const updates = pendingUpdates.current.splice(0);
2223
+ setState((prevState)=>{
2224
+ let newState = prevState;
2225
+ for (const update of updates){
2226
+ newState = typeof update === 'function' ? update(newState) : update;
2227
+ }
2228
+ return newState;
2229
+ });
2221
2230
  });
2222
2231
  }, []);
2223
2232
  useUnmount(()=>{
package/dist/index.d.cts CHANGED
@@ -3731,7 +3731,7 @@ declare const useFetchEventSource: UseFetchEventSource;
3731
3731
  * - reset: 將 map 重置為其初始狀態的函數。
3732
3732
  * - size: map 的當前大小。
3733
3733
  */
3734
- type UseMap<K = any, V = any> = (
3734
+ type UseMap = <K = any, V = any>(
3735
3735
  /**
3736
3736
  * @zh 初始值,可以为 Map 实例、数组或者一个初始化的函数
3737
3737
  * @zh-Hant 初始值,可以為 Map 實例、數組或者一個初始化的函數
package/dist/index.d.mts CHANGED
@@ -3731,7 +3731,7 @@ declare const useFetchEventSource: UseFetchEventSource;
3731
3731
  * - reset: 將 map 重置為其初始狀態的函數。
3732
3732
  * - size: map 的當前大小。
3733
3733
  */
3734
- type UseMap<K = any, V = any> = (
3734
+ type UseMap = <K = any, V = any>(
3735
3735
  /**
3736
3736
  * @zh 初始值,可以为 Map 实例、数组或者一个初始化的函数
3737
3737
  * @zh-Hant 初始值,可以為 Map 實例、數組或者一個初始化的函數
package/dist/index.d.ts CHANGED
@@ -3731,7 +3731,7 @@ declare const useFetchEventSource: UseFetchEventSource;
3731
3731
  * - reset: 將 map 重置為其初始狀態的函數。
3732
3732
  * - size: map 的當前大小。
3733
3733
  */
3734
- type UseMap<K = any, V = any> = (
3734
+ type UseMap = <K = any, V = any>(
3735
3735
  /**
3736
3736
  * @zh 初始值,可以为 Map 实例、数组或者一个初始化的函数
3737
3737
  * @zh-Hant 初始值,可以為 Map 實例、數組或者一個初始化的函數
package/dist/index.mjs CHANGED
@@ -2206,10 +2206,19 @@ const useMediaQuery = (query, defaultState)=>{
2206
2206
  function useRafState(initialState) {
2207
2207
  const frame = useRef(0);
2208
2208
  const [state, setState] = useState(initialState);
2209
+ const pendingUpdates = useRef([]);
2209
2210
  const setRafState = useCallback((value)=>{
2211
+ pendingUpdates.current.push(value);
2210
2212
  cancelAnimationFrame(frame.current);
2211
2213
  frame.current = requestAnimationFrame(()=>{
2212
- setState(value);
2214
+ const updates = pendingUpdates.current.splice(0);
2215
+ setState((prevState)=>{
2216
+ let newState = prevState;
2217
+ for (const update of updates){
2218
+ newState = typeof update === 'function' ? update(newState) : update;
2219
+ }
2220
+ return newState;
2221
+ });
2213
2222
  });
2214
2223
  }, []);
2215
2224
  useUnmount(()=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactuses/core",
3
- "version": "6.1.7",
3
+ "version": "6.1.9",
4
4
  "license": "Unlicense",
5
5
  "homepage": "https://www.reactuse.com/",
6
6
  "repository": {
@@ -75,7 +75,6 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@microsoft/fetch-event-source": "^2.0.1",
78
- "@testing-library/dom": "^10.4.0",
79
78
  "js-cookie": "^3.0.5",
80
79
  "lodash-es": "^4.17.21",
81
80
  "screenfull": "^5.0.0",
@@ -84,6 +83,7 @@
84
83
  "devDependencies": {
85
84
  "@jsdevtools/version-bump-prompt": "^6.1.0",
86
85
  "@reactuses/ts-document": "workspace:*",
86
+ "@testing-library/dom": "^10.4.0",
87
87
  "@testing-library/react": "^16.1.0",
88
88
  "@types/jest": "^27.5.2",
89
89
  "@types/js-cookie": "^3.0.3",