feat: tools normalized

This commit is contained in:
Ibrahima G. Coulibaly
2024-06-22 22:06:16 +01:00
parent 17ba68be34
commit 23f50ffead
36 changed files with 2625 additions and 1045 deletions

View File

@@ -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(() => {

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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.