Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] Fix crash when opening context menu #54832

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading