react-native-walkthrough-tooltip
Advanced tools
Comparing version
{ | ||
"name": "react-native-walkthrough-tooltip", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "An inline wrapper for calling out React Native components via tooltip", | ||
@@ -5,0 +5,0 @@ "main": "src/tooltip.js", |
@@ -91,12 +91,12 @@ # React Native Walkthrough Tooltip [](https://www.npmjs.com/package/react-native-walkthrough-tooltip) [](https://www.npmjs.com/package/react-native-walkthrough-tooltip) | ||
### TooltipChildrenConsumer | ||
### TooltipChildrenContext | ||
[React Context](https://reactjs.org/docs/context.html) consumer that can be used to distinguish "real" children rendered inside parent's layout from their copies rendered inside tooltip's modal. The duplicate child rendered in the tooltip modal is wrapped in a Context.Provider which provides object with prop `tooltipDuplicate` set to `true`, so informed decisions may be made, if necessary, based on where the child rendered. | ||
[React Context](https://reactjs.org/docs/context.html) that can be used to distinguish "real" children rendered inside parent's layout from their copies rendered inside tooltip's modal. The duplicate child rendered in the tooltip modal is wrapped in a Context.Provider which provides object with prop `tooltipDuplicate` set to `true`, so informed decisions may be made, if necessary, based on where the child rendered. | ||
```js | ||
import Tooltip, { TooltipChildrenConsumer } from 'react-native-walkthrough-tooltip'; | ||
import Tooltip, { TooltipChildrenContext } from 'react-native-walkthrough-tooltip'; | ||
... | ||
<Tooltip withContext> | ||
<Tooltip> | ||
<ComponentA /> | ||
<ComponentB> | ||
<TooltipChildrenConsumer> | ||
<TooltipChildrenContext.Consumer> | ||
{({ tooltipDuplicate }) => ( | ||
@@ -106,5 +106,5 @@ // will only assign a ref to the original component | ||
)} | ||
</WalkthroughConsumer> | ||
</TooltipChildrenContext.Consumer> | ||
</ComponentB> | ||
</Tooltip> | ||
``` |
@@ -92,5 +92,5 @@ // Type definitions for react-native-walkthrough-tooltip 0.5.3 | ||
// Usage Example | ||
import Tooltip, { TooltipChildrenConsumer } from 'react-native-walkthrough-tooltip'; | ||
import Tooltip, { TooltipChildrenContext } from 'react-native-walkthrough-tooltip'; | ||
<Tooltip> | ||
<TooltipChildrenConsumer> | ||
<TooltipChildrenContext.Consumer> | ||
{({ tooltipDuplicate }) => ( | ||
@@ -101,7 +101,7 @@ <ScrollView scrollEnabled={!tooltipDuplicate}> | ||
)} | ||
</TooltipChildrenConsumer> | ||
</TooltipChildrenContext.Consumer> | ||
</Tooltip> | ||
``` | ||
*/ | ||
export const TooltipChildrenConsumer: React.Consumer<{ tooltipDuplicate: boolean }>; | ||
export const TooltipChildrenContext: React.Context<{ tooltipDuplicate: boolean }>; | ||
@@ -108,0 +108,0 @@ /** |
@@ -25,2 +25,4 @@ import React, { Component } from 'react'; | ||
export { TooltipChildrenContext }; | ||
const SCREEN_HEIGHT = Dimensions.get('window').height; | ||
@@ -47,5 +49,2 @@ const SCREEN_WIDTH = Dimensions.get('window').width; | ||
const TooltipChildrenProvider = TooltipChildrenContext.Provider; | ||
export const TooltipChildrenConsumer = TooltipChildrenContext.Consumer; | ||
class Tooltip extends Component { | ||
@@ -532,5 +531,5 @@ static defaultProps = { | ||
> | ||
<TooltipChildrenProvider value={{ tooltipDuplicate: true }}> | ||
<TooltipChildrenContext.Provider value={{ tooltipDuplicate: true }}> | ||
{children} | ||
</TooltipChildrenProvider> | ||
</TooltipChildrenContext.Provider> | ||
</View> | ||
@@ -537,0 +536,0 @@ ); |
39137
-0.19%829
-0.12%