class ToggleMenu extends React.Component {
constructor(props) {
super(props);
this.state = {
visible: false
};
this.toggleMenu = this.toggleMenu.bind(this);
}
toggleMenu() {
this.setState({visible: !this.state.visible})
}
render() {
return (
<div>
<button onClick={this.toggleMenu}>Show Right Menu!</button>
{this.state.visible && <Menu alignment="right">
<MenuItem hash="first-page">First Page</MenuItem>
<MenuItem hash="second-page">Second Page</MenuItem>
<MenuItem hash="third-page">Third Page</MenuItem>
</Menu>}
</div>
);
}
}
댓글