@reactuses/core 5.0.11 → 5.0.12
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.cjs +48 -25
- package/dist/index.d.cts +27 -2
- package/dist/index.d.mts +27 -2
- package/dist/index.d.ts +27 -2
- package/dist/index.mjs +48 -25
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -266,16 +266,56 @@ const useCookie = (key, options = defaultOptions$1, defaultValue)=>{
|
|
|
266
266
|
];
|
|
267
267
|
};
|
|
268
268
|
|
|
269
|
+
const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useEffect;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* keep function reference immutable
|
|
273
|
+
*/ const useEvent = (fn)=>{
|
|
274
|
+
if (isDev) {
|
|
275
|
+
if (!isFunction(fn)) {
|
|
276
|
+
console.error(`useEvent expected parameter is a function, got ${typeof fn}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const handlerRef = React.useRef(fn);
|
|
280
|
+
useIsomorphicLayoutEffect(()=>{
|
|
281
|
+
handlerRef.current = fn;
|
|
282
|
+
}, [
|
|
283
|
+
fn
|
|
284
|
+
]);
|
|
285
|
+
return React.useCallback((...args)=>{
|
|
286
|
+
const fn = handlerRef.current;
|
|
287
|
+
return fn(...args);
|
|
288
|
+
}, []);
|
|
289
|
+
};
|
|
290
|
+
|
|
269
291
|
const useInterval = (callback, delay, options = defaultOptions$1)=>{
|
|
270
|
-
const immediate = options
|
|
292
|
+
const { immediate, controls } = options;
|
|
271
293
|
const savedCallback = useLatest(callback);
|
|
294
|
+
const isActive = React.useRef(false);
|
|
295
|
+
const timer = React.useRef(null);
|
|
296
|
+
const clean = ()=>{
|
|
297
|
+
timer.current && clearInterval(timer.current);
|
|
298
|
+
};
|
|
299
|
+
const resume = useEvent(()=>{
|
|
300
|
+
isActive.current = true;
|
|
301
|
+
timer.current = setInterval(()=>savedCallback.current(), delay || 0);
|
|
302
|
+
});
|
|
303
|
+
const pause = useEvent(()=>{
|
|
304
|
+
isActive.current = false;
|
|
305
|
+
clean();
|
|
306
|
+
});
|
|
272
307
|
React.useEffect(()=>{
|
|
273
308
|
if (immediate) {
|
|
274
309
|
savedCallback.current();
|
|
275
310
|
}
|
|
311
|
+
if (controls) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
276
314
|
if (delay !== null) {
|
|
277
|
-
|
|
278
|
-
return ()=>
|
|
315
|
+
resume();
|
|
316
|
+
return ()=>{
|
|
317
|
+
clean();
|
|
318
|
+
};
|
|
279
319
|
}
|
|
280
320
|
return undefined;
|
|
281
321
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -283,6 +323,11 @@ const useInterval = (callback, delay, options = defaultOptions$1)=>{
|
|
|
283
323
|
delay,
|
|
284
324
|
immediate
|
|
285
325
|
]);
|
|
326
|
+
return {
|
|
327
|
+
isActive,
|
|
328
|
+
pause,
|
|
329
|
+
resume
|
|
330
|
+
};
|
|
286
331
|
};
|
|
287
332
|
|
|
288
333
|
const padZero = (time)=>{
|
|
@@ -339,28 +384,6 @@ const useCountDown = (time, format = getHMSTime, callback)=>{
|
|
|
339
384
|
];
|
|
340
385
|
};
|
|
341
386
|
|
|
342
|
-
const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useEffect;
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* keep function reference immutable
|
|
346
|
-
*/ const useEvent = (fn)=>{
|
|
347
|
-
if (isDev) {
|
|
348
|
-
if (!isFunction(fn)) {
|
|
349
|
-
console.error(`useEvent expected parameter is a function, got ${typeof fn}`);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
const handlerRef = React.useRef(fn);
|
|
353
|
-
useIsomorphicLayoutEffect(()=>{
|
|
354
|
-
handlerRef.current = fn;
|
|
355
|
-
}, [
|
|
356
|
-
fn
|
|
357
|
-
]);
|
|
358
|
-
return React.useCallback((...args)=>{
|
|
359
|
-
const fn = handlerRef.current;
|
|
360
|
-
return fn(...args);
|
|
361
|
-
}, []);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
387
|
const useCounter = (initialValue = 0, max = null, min = null)=>{
|
|
365
388
|
// avoid exec init code every render
|
|
366
389
|
const initFunc = ()=>{
|
package/dist/index.d.cts
CHANGED
|
@@ -1323,7 +1323,7 @@ delay?: number | null,
|
|
|
1323
1323
|
* @zh 可选参数
|
|
1324
1324
|
* @en optional params
|
|
1325
1325
|
*/
|
|
1326
|
-
options?: UseIntervalOptions) =>
|
|
1326
|
+
options?: UseIntervalOptions) => Pausable;
|
|
1327
1327
|
/**
|
|
1328
1328
|
* @title UseIntervalOptions
|
|
1329
1329
|
*/
|
|
@@ -1333,6 +1333,31 @@ interface UseIntervalOptions {
|
|
|
1333
1333
|
* @en Whether to execute immediately.
|
|
1334
1334
|
*/
|
|
1335
1335
|
immediate?: boolean;
|
|
1336
|
+
/**
|
|
1337
|
+
* @zh 是否控制执行。
|
|
1338
|
+
* @en Whether to control execution.
|
|
1339
|
+
*/
|
|
1340
|
+
controls?: boolean;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* @title Pausable
|
|
1344
|
+
*/
|
|
1345
|
+
interface Pausable {
|
|
1346
|
+
/**
|
|
1347
|
+
* @en A ref indicate whether a pausable instance is active
|
|
1348
|
+
* @zh 一个 ref,指示一个 pausable 实例是否处于激活状态
|
|
1349
|
+
*/
|
|
1350
|
+
isActive: RefObject<boolean>;
|
|
1351
|
+
/**
|
|
1352
|
+
* @en Temporary pause the effect from executing
|
|
1353
|
+
* @zh 暂时暂停执行效果
|
|
1354
|
+
*/
|
|
1355
|
+
pause: () => void;
|
|
1356
|
+
/**
|
|
1357
|
+
* @en Resume the effects
|
|
1358
|
+
* @zh 恢复效果
|
|
1359
|
+
*/
|
|
1360
|
+
resume: () => void;
|
|
1336
1361
|
}
|
|
1337
1362
|
|
|
1338
1363
|
declare const useInterval: UseInterval;
|
|
@@ -2966,4 +2991,4 @@ defauleValue?: boolean) => boolean;
|
|
|
2966
2991
|
*/
|
|
2967
2992
|
type UseMobileLandscape = () => boolean;
|
|
2968
2993
|
|
|
2969
|
-
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
|
2994
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.d.mts
CHANGED
|
@@ -1323,7 +1323,7 @@ delay?: number | null,
|
|
|
1323
1323
|
* @zh 可选参数
|
|
1324
1324
|
* @en optional params
|
|
1325
1325
|
*/
|
|
1326
|
-
options?: UseIntervalOptions) =>
|
|
1326
|
+
options?: UseIntervalOptions) => Pausable;
|
|
1327
1327
|
/**
|
|
1328
1328
|
* @title UseIntervalOptions
|
|
1329
1329
|
*/
|
|
@@ -1333,6 +1333,31 @@ interface UseIntervalOptions {
|
|
|
1333
1333
|
* @en Whether to execute immediately.
|
|
1334
1334
|
*/
|
|
1335
1335
|
immediate?: boolean;
|
|
1336
|
+
/**
|
|
1337
|
+
* @zh 是否控制执行。
|
|
1338
|
+
* @en Whether to control execution.
|
|
1339
|
+
*/
|
|
1340
|
+
controls?: boolean;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* @title Pausable
|
|
1344
|
+
*/
|
|
1345
|
+
interface Pausable {
|
|
1346
|
+
/**
|
|
1347
|
+
* @en A ref indicate whether a pausable instance is active
|
|
1348
|
+
* @zh 一个 ref,指示一个 pausable 实例是否处于激活状态
|
|
1349
|
+
*/
|
|
1350
|
+
isActive: RefObject<boolean>;
|
|
1351
|
+
/**
|
|
1352
|
+
* @en Temporary pause the effect from executing
|
|
1353
|
+
* @zh 暂时暂停执行效果
|
|
1354
|
+
*/
|
|
1355
|
+
pause: () => void;
|
|
1356
|
+
/**
|
|
1357
|
+
* @en Resume the effects
|
|
1358
|
+
* @zh 恢复效果
|
|
1359
|
+
*/
|
|
1360
|
+
resume: () => void;
|
|
1336
1361
|
}
|
|
1337
1362
|
|
|
1338
1363
|
declare const useInterval: UseInterval;
|
|
@@ -2966,4 +2991,4 @@ defauleValue?: boolean) => boolean;
|
|
|
2966
2991
|
*/
|
|
2967
2992
|
type UseMobileLandscape = () => boolean;
|
|
2968
2993
|
|
|
2969
|
-
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
|
2994
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.d.ts
CHANGED
|
@@ -1323,7 +1323,7 @@ delay?: number | null,
|
|
|
1323
1323
|
* @zh 可选参数
|
|
1324
1324
|
* @en optional params
|
|
1325
1325
|
*/
|
|
1326
|
-
options?: UseIntervalOptions) =>
|
|
1326
|
+
options?: UseIntervalOptions) => Pausable;
|
|
1327
1327
|
/**
|
|
1328
1328
|
* @title UseIntervalOptions
|
|
1329
1329
|
*/
|
|
@@ -1333,6 +1333,31 @@ interface UseIntervalOptions {
|
|
|
1333
1333
|
* @en Whether to execute immediately.
|
|
1334
1334
|
*/
|
|
1335
1335
|
immediate?: boolean;
|
|
1336
|
+
/**
|
|
1337
|
+
* @zh 是否控制执行。
|
|
1338
|
+
* @en Whether to control execution.
|
|
1339
|
+
*/
|
|
1340
|
+
controls?: boolean;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* @title Pausable
|
|
1344
|
+
*/
|
|
1345
|
+
interface Pausable {
|
|
1346
|
+
/**
|
|
1347
|
+
* @en A ref indicate whether a pausable instance is active
|
|
1348
|
+
* @zh 一个 ref,指示一个 pausable 实例是否处于激活状态
|
|
1349
|
+
*/
|
|
1350
|
+
isActive: RefObject<boolean>;
|
|
1351
|
+
/**
|
|
1352
|
+
* @en Temporary pause the effect from executing
|
|
1353
|
+
* @zh 暂时暂停执行效果
|
|
1354
|
+
*/
|
|
1355
|
+
pause: () => void;
|
|
1356
|
+
/**
|
|
1357
|
+
* @en Resume the effects
|
|
1358
|
+
* @zh 恢复效果
|
|
1359
|
+
*/
|
|
1360
|
+
resume: () => void;
|
|
1336
1361
|
}
|
|
1337
1362
|
|
|
1338
1363
|
declare const useInterval: UseInterval;
|
|
@@ -2966,4 +2991,4 @@ defauleValue?: boolean) => boolean;
|
|
|
2966
2991
|
*/
|
|
2967
2992
|
type UseMobileLandscape = () => boolean;
|
|
2968
2993
|
|
|
2969
|
-
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
|
2994
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.mjs
CHANGED
|
@@ -259,16 +259,56 @@ const useCookie = (key, options = defaultOptions$1, defaultValue)=>{
|
|
|
259
259
|
];
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
+
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* keep function reference immutable
|
|
266
|
+
*/ const useEvent = (fn)=>{
|
|
267
|
+
if (isDev) {
|
|
268
|
+
if (!isFunction(fn)) {
|
|
269
|
+
console.error(`useEvent expected parameter is a function, got ${typeof fn}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const handlerRef = useRef(fn);
|
|
273
|
+
useIsomorphicLayoutEffect(()=>{
|
|
274
|
+
handlerRef.current = fn;
|
|
275
|
+
}, [
|
|
276
|
+
fn
|
|
277
|
+
]);
|
|
278
|
+
return useCallback((...args)=>{
|
|
279
|
+
const fn = handlerRef.current;
|
|
280
|
+
return fn(...args);
|
|
281
|
+
}, []);
|
|
282
|
+
};
|
|
283
|
+
|
|
262
284
|
const useInterval = (callback, delay, options = defaultOptions$1)=>{
|
|
263
|
-
const immediate = options
|
|
285
|
+
const { immediate, controls } = options;
|
|
264
286
|
const savedCallback = useLatest(callback);
|
|
287
|
+
const isActive = useRef(false);
|
|
288
|
+
const timer = useRef(null);
|
|
289
|
+
const clean = ()=>{
|
|
290
|
+
timer.current && clearInterval(timer.current);
|
|
291
|
+
};
|
|
292
|
+
const resume = useEvent(()=>{
|
|
293
|
+
isActive.current = true;
|
|
294
|
+
timer.current = setInterval(()=>savedCallback.current(), delay || 0);
|
|
295
|
+
});
|
|
296
|
+
const pause = useEvent(()=>{
|
|
297
|
+
isActive.current = false;
|
|
298
|
+
clean();
|
|
299
|
+
});
|
|
265
300
|
useEffect(()=>{
|
|
266
301
|
if (immediate) {
|
|
267
302
|
savedCallback.current();
|
|
268
303
|
}
|
|
304
|
+
if (controls) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
269
307
|
if (delay !== null) {
|
|
270
|
-
|
|
271
|
-
return ()=>
|
|
308
|
+
resume();
|
|
309
|
+
return ()=>{
|
|
310
|
+
clean();
|
|
311
|
+
};
|
|
272
312
|
}
|
|
273
313
|
return undefined;
|
|
274
314
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -276,6 +316,11 @@ const useInterval = (callback, delay, options = defaultOptions$1)=>{
|
|
|
276
316
|
delay,
|
|
277
317
|
immediate
|
|
278
318
|
]);
|
|
319
|
+
return {
|
|
320
|
+
isActive,
|
|
321
|
+
pause,
|
|
322
|
+
resume
|
|
323
|
+
};
|
|
279
324
|
};
|
|
280
325
|
|
|
281
326
|
const padZero = (time)=>{
|
|
@@ -332,28 +377,6 @@ const useCountDown = (time, format = getHMSTime, callback)=>{
|
|
|
332
377
|
];
|
|
333
378
|
};
|
|
334
379
|
|
|
335
|
-
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* keep function reference immutable
|
|
339
|
-
*/ const useEvent = (fn)=>{
|
|
340
|
-
if (isDev) {
|
|
341
|
-
if (!isFunction(fn)) {
|
|
342
|
-
console.error(`useEvent expected parameter is a function, got ${typeof fn}`);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
const handlerRef = useRef(fn);
|
|
346
|
-
useIsomorphicLayoutEffect(()=>{
|
|
347
|
-
handlerRef.current = fn;
|
|
348
|
-
}, [
|
|
349
|
-
fn
|
|
350
|
-
]);
|
|
351
|
-
return useCallback((...args)=>{
|
|
352
|
-
const fn = handlerRef.current;
|
|
353
|
-
return fn(...args);
|
|
354
|
-
}, []);
|
|
355
|
-
};
|
|
356
|
-
|
|
357
380
|
const useCounter = (initialValue = 0, max = null, min = null)=>{
|
|
358
381
|
// avoid exec init code every render
|
|
359
382
|
const initFunc = ()=>{
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactuses/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.12",
|
|
4
4
|
"license": "Unlicense",
|
|
5
5
|
"homepage": "https://www.reactuse.com/",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/childrentime/reactuse",
|
|
8
|
+
"url": "git+https://github.com/childrentime/reactuse.git",
|
|
9
9
|
"directory": "packages/core"
|
|
10
10
|
},
|
|
11
11
|
"bugs": {
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"esbuild-register": "^3.4.1",
|
|
79
79
|
"jest": "^29.0.2",
|
|
80
80
|
"jest-environment-jsdom": "^29.0.2",
|
|
81
|
+
"jest-environment-node": "^29.7.0",
|
|
81
82
|
"lodash": "^4.17.21",
|
|
82
83
|
"react": "^18.2.0",
|
|
83
84
|
"react-dom": "^18.2.0",
|