1- import React , { FC , ReactElement , memo , useLayoutEffect } from 'react' ;
1+ import React , { FC , ReactElement , useCallback , useLayoutEffect } from 'react' ;
22import { ScrollView , Text , TouchableOpacity , View } from 'react-native' ;
33
44import AsyncStorage from '@react-native-async-storage/async-storage' ;
@@ -25,39 +25,36 @@ const Page: FC = () => {
2525 const navigation = useNavigation < RootStackNavigationProps < 'default' > > ( ) ;
2626 const { theme} = useTheme ( ) ;
2727
28- const pressAgree = async ( ) : Promise < void > => {
28+ const pressAgree = useCallback ( async ( ) : Promise < void > => {
2929 await AsyncStorage . setItem ( 'license_agreed' , JSON . stringify ( true ) ) ;
3030 navigation . pop ( ) ;
31- } ;
31+ } , [ navigation ] ) ;
3232
33- const headerRight = memo (
34- ( ) : ReactElement => (
35- < TouchableOpacity testID = "touch-done" onPress = { pressAgree } >
36- < View
37- style = { {
38- paddingHorizontal : 16 ,
39- paddingVertical : 8 ,
40- } }
41- >
42- < Text
33+ useLayoutEffect ( ( ) => {
34+ navigation . setOptions ( {
35+ // eslint-disable-next-line react/no-unstable-nested-components
36+ headerRight : ( ) : ReactElement => (
37+ < TouchableOpacity testID = "touch-done" onPress = { pressAgree } >
38+ < View
4339 style = { {
44- color : theme . text ,
45- fontSize : 14 ,
46- fontWeight : 'bold' ,
40+ paddingHorizontal : 16 ,
41+ paddingVertical : 8 ,
4742 } }
4843 >
49- { getString ( 'AGREE' ) }
50- </ Text >
51- </ View >
52- </ TouchableOpacity >
53- ) ,
54- ) ;
55-
56- useLayoutEffect ( ( ) => {
57- navigation . setOptions ( {
58- headerRight,
44+ < Text
45+ style = { {
46+ color : theme . text ,
47+ fontSize : 14 ,
48+ fontWeight : 'bold' ,
49+ } }
50+ >
51+ { getString ( 'AGREE' ) }
52+ </ Text >
53+ </ View >
54+ </ TouchableOpacity >
55+ ) ,
5956 } ) ;
60- } , [ headerRight , navigation ] ) ;
57+ } , [ pressAgree , navigation , theme . text ] ) ;
6158
6259 return (
6360 < Container >
0 commit comments