Skip to content

Instantly share code, notes, and snippets.

@chrisirhc
Created January 31, 2016 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisirhc/b80fe6a9c66b167c82d9 to your computer and use it in GitHub Desktop.
Save chrisirhc/b80fe6a9c66b167c82d9 to your computer and use it in GitHub Desktop.
DOM diffing, DOM shape, and mouse events (First version)
class HasTooltip extends React.Component {
/* … */
_renderPlaceholder() {
return (
<div className="has-tooltip"
onMouseEnter={this._setHovered}
onMouseLeave={this._setNotHovered}
></div>
);
}
render() {
const placeholder = this._renderPlaceholder();
const {isHovered} = this.state;
return isHovered ? (
<div className="tooltip-region">
{ placeholder }
<div>Hello</div>
</div>
) : placeholder;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment