From 66102abc5eb3eb26d5b647f2acabfba4966e789f Mon Sep 17 00:00:00 2001 From: Emanuel Quimper Date: Fri, 28 Jun 2024 15:32:21 -0400 Subject: [PATCH] fix(flick): fix flick with useLayoutEffect --- src/Provider.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Provider.tsx b/src/Provider.tsx index 2b12d98..7cede1c 100644 --- a/src/Provider.tsx +++ b/src/Provider.tsx @@ -1,6 +1,6 @@ import React, { useCallback, - useEffect, + useLayoutEffect, useMemo, useState, type PropsWithChildren, @@ -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]);