react-pdf-highlighter
react-pdf-highlighter copied to clipboard
Bad callback if TipContainer deleted before callback complete
https://github.com/agentcooper/react-pdf-highlighter/blob/cd44de6c1652325a626776db72002a10b74e6369/packages/react-pdf-highlighter/src/components/TipContainer.js#L34
This line sets up a callback; however, if the TipContainer is deleted before the callback completes you get a "cannot use blah of undefined" error as the this is now pointing to the Window.
I fixed it like so:
timer = null;
componentDidMount() {
this.timer = setTimeout(() => { this.updatePosition() }, 0);
}
componentWillUnmount() {
clearTimeout(this.timer);
}