mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
feat(useFirstMountState): hook to track if render is first; feat(useRendersCount): hook to track renders count; refactor(useUpdateEffect): now uses useFirstMountState hook; refactor(usePreviousDistinct): now uses with useFirstMountState hook; docs: update readme;
13 lines
302 B
TypeScript
13 lines
302 B
TypeScript
import { useEffect } from 'react';
|
|
import { useFirstMountState } from './useFirstMountState';
|
|
|
|
const useUpdateEffect: typeof useEffect = (effect, deps) => {
|
|
const isFirstMount = useFirstMountState();
|
|
|
|
useEffect(() => {
|
|
!isFirstMount && effect();
|
|
}, deps);
|
|
};
|
|
|
|
export default useUpdateEffect;
|