mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 14:09:31 +02:00
feat: tools normalized
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {useCallback, useEffect, useRef} from "react";
|
||||
import _ from "lodash";
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
import _ from 'lodash';
|
||||
|
||||
/**
|
||||
* Debounce hook.
|
||||
@@ -9,7 +9,7 @@ import _ from "lodash";
|
||||
*/
|
||||
function useDebounce<T extends (...args: never[]) => void>(
|
||||
callback: T,
|
||||
delay: number,
|
||||
delay: number
|
||||
): T {
|
||||
const callbackRef = useRef<T>(callback);
|
||||
|
||||
@@ -22,7 +22,7 @@ function useDebounce<T extends (...args: never[]) => void>(
|
||||
_.debounce((...args: never[]) => {
|
||||
callbackRef.current(...args);
|
||||
}, delay),
|
||||
[delay],
|
||||
[delay]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
/**
|
||||
* The usePrevious function is a custom hook that returns the previous value of a variable.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
/**
|
||||
* The useTimeout function is a custom hook that sets a timeout for a given callback function.
|
||||
@@ -15,7 +15,7 @@ function useTimeout(callback: () => void, delay: number) {
|
||||
useEffect(() => {
|
||||
let timer: NodeJS.Timeout | undefined;
|
||||
|
||||
if (delay !== null && callback && typeof callback === "function") {
|
||||
if (delay !== null && callback && typeof callback === 'function') {
|
||||
timer = setTimeout(callbackRef.current, delay);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { DependencyList, EffectCallback, useEffect, useRef } from "react";
|
||||
import { DependencyList, EffectCallback, useEffect, useRef } from 'react';
|
||||
|
||||
/**
|
||||
* The useUpdateEffect function is a custom hook that behaves like useEffect, but only runs on updates and not on initial mount.
|
||||
|
Reference in New Issue
Block a user