react-native-tooltip icon indicating copy to clipboard operation
react-native-tooltip copied to clipboard

Tooltip disappearing after first tap

Open FranDepascuali opened this issue 7 years ago • 2 comments

Hey there! First of all, thanks for this cool library. It has been working great.

We are having an issue when displaying the tooltip the first time after the user opens the app. output

The tooltip dissapears that first time. After that, it works correctly:

output

The code is simple:

export default class ContextMenu extends React.PureComponent {
  componentWillUnmount() {
    if (this.ref) {
      this.ref.hideMenu();
      delete this.ref;
    }
  }

  setRef = (ref) => {
    if (!ref) {
      return;
    }

    this.ref = ref;
    if (ref) {
      setTimeout(() => {
        if (this.ref) {
          this.ref.showMenu();
        }
      }, 100);
    }
  }

  render() {
    const actions = getActions(this.props);

    return (
      <ToolTip
        actions={actions}
        ref={this.setRef}
      >
        <View />
      </ToolTip>
    );
  }
}

Note that we had to introduce that delay because the tooltip doesn't appear when placed in componentDidMount. I tried to debug this, as I thought that a hideMenu() was being called, but it wasn't. showMenu() is called correctly and then the context menu disappears without a call to hideMenu().

Any help would be appreciated, thanks!

FranDepascuali avatar Aug 16 '18 17:08 FranDepascuali

@FranDepascuali did you find a way to solve this? it's happening with me too :/

ded3zito avatar Aug 12 '20 18:08 ded3zito

@andrewdazs no longer working with RN, sorry!

FranDepascuali avatar Aug 23 '20 18:08 FranDepascuali