Skip to content

Instantly share code, notes, and snippets.

@eduard-tkv
Created March 28, 2017 13:11
Show Gist options
  • Save eduard-tkv/2253777c24fec7be03c5b91a27ad4456 to your computer and use it in GitHub Desktop.
Save eduard-tkv/2253777c24fec7be03c5b91a27ad4456 to your computer and use it in GitHub Desktop.
import React from 'react';
const STATUS = {
HOVERED: 'hovered',
NORMAL: 'normal',
};
export default class Link extends React.Component {
constructor(props) {
super(props);
this._onMouseEnter = this._onMouseEnter.bind(this);
this._onMouseLeave = this._onMouseLeave.bind(this);
this.state = {
class: STATUS.NORMAL,
};
}
_onMouseEnter() {
this.setState({class: STATUS.HOVERED});
}
_onMouseLeave() {
this.setState({class: STATUS.NORMAL});
}
render() {
return (
<a
className={this.state.class}
href={this.props.page || '#'}
onMouseEnter={this._onMouseEnter}
onMouseLeave={this._onMouseLeave}>
{this.props.children}
</a>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment