diff --git a/src/useFirstMountState.ts b/src/useFirstMountState.ts index cf210622a2..9c8121f5e5 100644 --- a/src/useFirstMountState.ts +++ b/src/useFirstMountState.ts @@ -1,13 +1,14 @@ -import { useRef } from 'react'; +import { useEffect, useRef } from 'react'; export function useFirstMountState(): boolean { const isFirst = useRef(true); - if (isFirst.current) { + useEffect(() => { isFirst.current = false; - - return true; - } + return () => { + isFirst.current = true; + }; + }, []); return isFirst.current; }