jasongaare / react-native-walkthrough-tooltip

An inline wrapper for calling out React Native components via tooltip
MIT License
610 stars 182 forks source link

childrenProps property #148

Open darkerthanblackoff opened 2 years ago

darkerthanblackoff commented 2 years ago

Sometimes it becomes necessary to change the appearance of child components when they are rendered on top of the overlay. For example, I wrapped an icon with black text in a tooltip, the text will be hard to see because of the overlay and I need the ability to change it to white only when the tooltip is visible. Can you add something like childrenProps property? Also it will be grate if it will work with array of child components, because sometimes it's need to wrap more than one component.

apfritts commented 2 years ago

Have you tried using TooltipChildrenContext?

import {TooltipChildrenContext} from 'react-native-walkthrough-tooltip'

...

render() {
  return (
    <TooltipChildrenContext.Consumer>
      {({tooltipDuplicate}) => (
          <View>
            <Text>Is child? {tooltipDuplicate ? 'yes' : 'no'}</Text>
          </View>
        )
      }
    </TooltipChildrenContext.Consumer>
  )
}