react-native-walkthrough-tooltip
react-native-walkthrough-tooltip copied to clipboard
Can't perform a React state update on an unmounted component
I have this error, and the error tells me it's from Tooltip! My components can sometimes mount / unmount very quickly, however, I protect my state updates so that they only run if the component they are called from is mounted.
This is my code where the tooltip is defined:
<Tooltip
isVisible={isVisible}
content={...}
placement="top"
onClose={onExitModal}
backgroundColor="#00000040"
contentStyle={ownStyles.tooltip}
tooltipStyle={SHADOWS.default}
useInteractionManager={true}
showChildInTooltip={true}
allowChildInteraction={false}
childContentSpacing={20}
>
<TooltipChildrenContext.Consumer>
{
({ tooltipDuplicate }) => (
<TouchableWithoutFeedback
onPress={() =>{
this.HeartBounceRef && this.HeartBounceRef.animate(ANIMATIONS.heartBounce)
onPressHeart && onPressHeart()
}}
disabled={isButtonLoading}
>
<Animatable.View
ref={(ref) => {
if (!tooltipDuplicate)
this.HeartBounceRef = ref
}}
duration={300}
easing="ease-out-back"
useNativeDriver={true}
>
{...}
</Animatable.View>
</TouchableWithoutFeedback>
)
}
</TooltipChildrenContext.Consumer>
</Tooltip>
This is a Pure Component.
And now, the error:


@jasongaare Hello, thanks for this awesome package :)
It seems like the problem is still here and this code causes memory leak:
setTimeout(() => {
this.measureChildRect();
});
You can create a variable mounted and assign it to false on componentWillUnmount method and then check if the component is mounted this way:
if(mounted) {
setTimeout(() => {
this.measureChildRect();
});
}
Hi 👋🏼
I'm not opposed to the mounted idea, if you don't mind making a PR, I'd love to get it in there!
Has there been any update on the mounted setstate making it into the code? I'm also running into this issue currently
Still running into this issue, unfortunately.
I'm still having this issue
Still having this issue