// @flow import React from 'react'; import classnames from 'classnames'; import Icon from 'component/common/icon'; import Button from 'component/button'; import * as icons from 'constants/icons'; type Props = { body: string, label: string, }; type State = { showTooltip: boolean, }; class ToolTip extends React.PureComponent { constructor(props: Props) { super(props); this.state = { showTooltip: false, }; (this: any).handleClick = this.handleClick.bind(this); } handleClick() { const { showTooltip } = this.state; if (!showTooltip) { document.addEventListener('click', this.handleClick); } else { document.removeEventListener('click', this.handleClick); } this.setState({ showTooltip: !showTooltip, }); } render() { const { label, body } = this.props; const { showTooltip } = this.state; return (
{body}
); } } export default ToolTip;