Skip to content

Commit 66102ab

Browse files
committed
fix(flick): fix flick with useLayoutEffect
1 parent 3606633 commit 66102ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Provider.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {
22
useCallback,
3-
useEffect,
3+
useLayoutEffect,
44
useMemo,
55
useState,
66
type PropsWithChildren,
@@ -136,9 +136,10 @@ export function useFormSmartScroll({
136136

137137
const currentFocus = useAtomValue(currentFocusAtom);
138138

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

0 commit comments

Comments
 (0)