Last active
July 11, 2017 17:47
-
-
Save dvtng/57f4d3663a37be7bf9bd1d1dbce8353c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Document extends React.Component { | |
componentDidMount() { | |
ReactDOM.findDOMNode(this).addEventListener('click', this.onClick); | |
} | |
componentWillUnmount() { | |
ReactDOM.findDOMNode(this).removeEventListener('click', this.onClick); | |
} | |
onClick = (e) => { | |
if (e.target.tagName === 'A') { // Naive check for <a> elements | |
sendAnalytics('link clicked', { | |
documentId: this.props.documentId // Specific information to be sent | |
}); | |
} | |
}; | |
render() { | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You shouldn't be using findDOMNode