1- import React , { useEffect , useState } from 'react' ;
2- import { InteractionManager , View } from 'react-native' ;
1+ import React from 'react' ;
2+ import { View } from 'react-native' ;
33import Button from '@components/Button' ;
44import HeaderGap from '@components/HeaderGap' ;
55import Text from '@components/Text' ;
66import useLocalize from '@hooks/useLocalize' ;
7+ import useRefreshKeyAfterInteraction from '@hooks/useRefreshKeyAfterInteraction' ;
78import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
89import useThemeStyles from '@hooks/useThemeStyles' ;
9- import getPlatform from '@libs/getPlatform' ;
10- import CONST from '@src/CONST' ;
1110
1211type TestDriveBannerProps = {
1312 /** Callback to finish the test drive */
@@ -18,31 +17,20 @@ function TestDriveBanner({onPress}: TestDriveBannerProps) {
1817 const styles = useThemeStyles ( ) ;
1918 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
2019 const { translate} = useLocalize ( ) ;
21- const [ refreshKey , setRefreshKey ] = useState ( 0 ) ;
2220
2321 // Forcing a key change here forces React to fully re-mount this component
2422 // This helps reset the underlying drag region boundaries so that
2523 // interactive elements (like buttons) become clickable again after certain UI changes.
2624 // Without this, the OS-level drag region overlap clickable elements,
2725 // making them unresponsive until the container is refreshed.
2826 // For more context: https://github.com/Expensify/App/issues/68139
29- useEffect ( ( ) => {
30- const isDesktop = getPlatform ( ) === CONST . PLATFORM . DESKTOP ;
31-
32- if ( ! isDesktop ) {
33- return ;
34- }
35-
36- InteractionManager . runAfterInteractions ( ( ) => {
37- setRefreshKey ( ( prev ) => prev + 1 ) ;
38- } ) ;
39- } , [ ] ) ;
27+ const key = useRefreshKeyAfterInteraction ( 'key' ) ;
4028
4129 return (
4230 < View
4331 style = { [ styles . highlightBG ] }
4432 dataSet = { { dragArea : false } }
45- key = { refreshKey }
33+ key = { key }
4634 >
4735 < HeaderGap styles = { styles . testDriveBannerGap } />
4836 < View style = { [ styles . gap2 , styles . alignItemsCenter , styles . flexRow , styles . justifyContentCenter , styles . h10 ] } >
0 commit comments