feat: Split string

This commit is contained in:
Ibrahima G. Coulibaly
2024-06-19 21:18:35 +01:00
parent 93113b15eb
commit 19f0de8909
18 changed files with 305 additions and 20 deletions

View File

@@ -0,0 +1,19 @@
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.
* It takes in an effect function and an optional dependency list as parameters.
* It returns nothing.
*/
const useUpdateEffect = (effect: EffectCallback, deps?: DependencyList) => {
const isInitialMount = useRef(true);
useEffect(() => {
if (isInitialMount.current) {
isInitialMount.current = false;
}
return effect();
}, deps);
};
export default useUpdateEffect;