File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,9 +94,10 @@ const FullScreenLocationPicker: React.FC<FullScreenLocationPickerProps> = ({ ini
9494 return ;
9595 }
9696
97- // Create a timeout promise
97+ // Create a timeout promise with cleanup
98+ let timeoutId : ReturnType < typeof setTimeout > | undefined ;
9899 const timeoutPromise = new Promise < never > ( ( _ , reject ) => {
99- setTimeout ( ( ) => reject ( new Error ( 'Location timeout' ) ) , LOCATION_TIMEOUT ) ;
100+ timeoutId = setTimeout ( ( ) => reject ( new Error ( 'Location timeout' ) ) , LOCATION_TIMEOUT ) ;
100101 } ) ;
101102
102103 // Race between getting location and timeout
@@ -107,6 +108,9 @@ const FullScreenLocationPicker: React.FC<FullScreenLocationPickerProps> = ({ ini
107108 timeoutPromise ,
108109 ] ) ;
109110
111+ // Clear timeout if location resolved first
112+ if ( timeoutId !== undefined ) clearTimeout ( timeoutId ) ;
113+
110114 if ( ! isMountedRef . current ) return ;
111115
112116 const newLocation = {
You can’t perform that action at this time.
0 commit comments