struct-ui-components
Version:
A collection of reusable, customizable React components built with TypeScript, Tailwind CSS, and Storybook. Designed for modern UI development with flexibility and scalability.
17 lines (14 loc) • 368 B
text/typescript
import { useEffect, useRef } from "react";
export const useUpdateEffect = (
callback: () => void | (() => void),
dependencies: React.DependencyList,
) => {
const firstRenderRef = useRef<boolean>(true);
useEffect(() => {
if (firstRenderRef.current) {
firstRenderRef.current = false;
return;
}
return callback();
}, dependencies);
};