Skip to content

Instantly share code, notes, and snippets.

@chrisirhc
Last active January 31, 2016 00:39
Show Gist options
  • Save chrisirhc/903b00425f2bc500e2f6 to your computer and use it in GitHub Desktop.
Save chrisirhc/903b00425f2bc500e2f6 to your computer and use it in GitHub Desktop.
DOM diffing, DOM shape, and mouse events (Best practice)
// Best practice, to maintain a similar DOM shape
render() {
const {isHovered} = this.state;
return (
<div className={classNames(isHovered && 'tooltip-region')}
onMouseEnter={this._setHovered}
onMouseLeave={this._setNotHovered}>
<div className="has-tooltip"></div>
{isHovered && <div>Hello</div>}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment