react-native-walkthrough-tooltip
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "react-native-walkthrough-tooltip", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "An inline wrapper for calling out React Native components via tooltip", | ||
@@ -5,0 +5,0 @@ "main": "src/tooltip.js", |
@@ -47,2 +47,5 @@ // Type definitions for react-native-walkthrough-tooltip 1.0.0 | ||
childrenWrapperStyle?: StyleProp<ViewStyle>; | ||
// Styles the view element that wraps the original children | ||
parentWrapperStyle?: StyleProp<ViewStyle> | ||
} | ||
@@ -49,0 +52,0 @@ |
@@ -117,2 +117,3 @@ import React, { Component } from 'react'; | ||
this.interactionPromise = null; | ||
this.dimensionsSubscription = null; | ||
@@ -141,3 +142,6 @@ this.childWrapper = React.createRef(); | ||
componentDidMount() { | ||
Dimensions.addEventListener('change', this.updateWindowDims); | ||
this.dimensionsSubscription = Dimensions.addEventListener( | ||
'change', | ||
this.updateWindowDims, | ||
); | ||
} | ||
@@ -162,3 +166,12 @@ | ||
componentWillUnmount() { | ||
Dimensions.removeEventListener('change', this.updateWindowDims); | ||
// removeEventListener deprecated | ||
// https://reactnative.dev/docs/dimensions#removeeventlistener | ||
if (this.dimensionsSubscription?.remove) { | ||
// react native >= 0.65.* | ||
this.dimensionsSubscription.remove(); | ||
} else { | ||
// react native < 0.65.* | ||
Dimensions.removeEventListener('change', this.updateWindowDims); | ||
} | ||
if (this.interactionPromise) { | ||
@@ -434,3 +447,8 @@ this.interactionPromise.cancel(); | ||
render() { | ||
const { children, isVisible, useReactNativeModal, modalComponent } = this.props; | ||
const { | ||
children, | ||
isVisible, | ||
useReactNativeModal, | ||
modalComponent, | ||
} = this.props; | ||
@@ -456,3 +474,7 @@ const hasChildren = React.Children.count(children) > 0; | ||
{hasChildren ? ( | ||
<View ref={this.childWrapper} onLayout={this.measureChildRect}> | ||
<View | ||
ref={this.childWrapper} | ||
onLayout={this.measureChildRect} | ||
style={this.props.parentWrapperStyle} | ||
> | ||
{children} | ||
@@ -459,0 +481,0 @@ </View> |
48559
1103