Skip to content

Commit

Permalink
Merge pull request #54832 from rayane-djouah/fix-crash-bug
Browse files Browse the repository at this point in the history
[CP Staging] Fix crash when opening context menu

(cherry picked from commit 4bab245)

(CP triggered by puneetlath)
  • Loading branch information
MonilBhavsar authored and OSBotify committed Jan 6, 2025
1 parent e92b470 commit 3674da3
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useNavigation} from '@react-navigation/native';
import React, {memo, useEffect, useRef, useState} from 'react';
import {NavigationContext} from '@react-navigation/native';
import React, {memo, useContext, useEffect, useRef, useState} from 'react';
import type {LayoutRectangle, NativeSyntheticEvent} from 'react-native';
import GenericTooltip from '@components/Tooltip/GenericTooltip';
import type {EducationalTooltipProps} from '@components/Tooltip/types';
Expand All @@ -17,7 +17,7 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
const [shouldMeasure, setShouldMeasure] = useState(false);
const show = useRef<() => void>();

const navigation = useNavigation();
const navigator = useContext(NavigationContext);

useEffect(() => {
return () => {
Expand All @@ -43,14 +43,17 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
}, [shouldMeasure, shouldRender]);

useEffect(() => {
const unsubscribe = navigation.addListener('blur', () => {
if (!navigator) {
return;
}
const unsubscribe = navigator.addListener('blur', () => {
if (!shouldHideOnNavigate) {
return;
}
hideTooltipRef.current?.();
});
return unsubscribe;
}, [navigation, shouldHideOnNavigate]);
}, [navigator, shouldHideOnNavigate]);

return (
<GenericTooltip
Expand Down

0 comments on commit 3674da3

Please sign in to comment.