Closed danielprogramic closed 6 years ago
hey @danielprogramic, thanks for checking out vx!
my first thought is that you could call this.props.onMouseMove
this.props.showTooltip
within the component's componentDidMount
lifecycle method. would that work?
you should be able to do:
componentDidMount() {
const { showTooltip } = this.props;
showTooltip({
tooltipData: {}, // whatever
tooltipLeft: x, // some number
tooltipTop: y, // some number
})
}
some notes from the React lifecycle docs https://reactjs.org/docs/react-component.html#componentdidmount:
You may call setState() immediately in componentDidMount(). It will trigger an extra rendering, but it will happen before the browser updates the screen. This guarantees that even though the render() will be called twice in this case, the user won’t see the intermediate state. Use this pattern with caution because it often causes performance issues. In most cases, you should be able to assign the initial state in the constructor() instead. It can, however, be necessary for cases like modals and tooltips when you need to measure a DOM node before rendering something that depends on its size or position.
Hi guys, Thank you for your assistance,
I was able to use the method showTooltip in the componentDidMount
componentDidMount() { const { showTooltip } = this.props; showTooltip({ tooltipData: {date: "2017", price: 100}, tooltipLeft: 150, tooltipTop: 67.5, }) }
But, I have a problem. How do I get the tooltipData, tooltipLeft and tooltipTop of all graphs?
I want the circle to appear on all the graphs, not only by the onMouseMove,onMouseLeave, onTouchMove
Demo the problem http://www.danielprogramic.com.br/problem/videotogif_2018.07.13_12.02.11.gif
Thanks guys
The tooltipData only works on onMouseMove and onMouseLeave, I'd like to use it with onload but, I can't to use