diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index 3be671446fb3..7547a6be9249 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -1,5 +1,5 @@ import {useRoute} from '@react-navigation/native'; -import React, {useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; +import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; // eslint-disable-next-line no-restricted-imports import type {GestureResponderEvent, ScrollView as RNScrollView, ScrollViewProps, StyleProp, ViewStyle} from 'react-native'; import {View} from 'react-native'; @@ -466,19 +466,14 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa [route, saveScrollOffset], ); - const [isAfterOnLayout, setIsAfterOnLayout] = useState(false); - - const onLayout = useCallback(() => { + useLayoutEffect(() => { const scrollOffset = getScrollOffset(route); - setIsAfterOnLayout(true); if (!scrollOffset || !scrollViewRef.current) { return; } scrollViewRef.current.scrollTo({y: scrollOffset, animated: false}); }, [getScrollOffset, route]); - const scrollOffset = getScrollOffset(route); - return ( {headerContent}