Skip to content

Commit

Permalink
fix(flick): fix flick with useLayoutEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
EQuimper committed Jun 28, 2024
1 parent 3606633 commit 66102ab
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {
useCallback,
useEffect,
useLayoutEffect,
useMemo,
useState,
type PropsWithChildren,
Expand Down Expand Up @@ -136,9 +136,10 @@ export function useFormSmartScroll({

const currentFocus = useAtomValue(currentFocusAtom);

useEffect(() => {
// we have a flick on first focus so we make the scrollview wait a bit before animate
useLayoutEffect(() => {
if (currentFocus && !isReady) {
setTimeout(() => setIsReady(true), 100);
setTimeout(() => setIsReady(true), isAndroid ? 250 : 100);
}
}, [currentFocus]);

Expand Down

0 comments on commit 66102ab

Please sign in to comment.