Skip to content

Instantly share code, notes, and snippets.

@abinavseelan
Last active February 23, 2018 10:31
Show Gist options
  • Save abinavseelan/ccb096f91fb8cbd3258e509fdb1e192a to your computer and use it in GitHub Desktop.
Save abinavseelan/ccb096f91fb8cbd3258e509fdb1e192a to your computer and use it in GitHub Desktop.
Component for a dropdown interaction (3)
import React, { Component } from 'react';
class Card extends Component {
constructor() {
super();
this.state = {
showMenu: false,
}
this.showMenu = this.showMenu.bind(this);
}
showMenu(event) {
event.preventDefault();
this.setState({
showMenu: true,
});
}
render() {
return (
<div>
<button onClick={this.showMenu}>
Show menu
</button>
{
this.state.showMenu
? (
<div className="menu">
<button> Menu item 1 </button>
<button> Menu item 2 </button>
<button> Menu item 3 </button>
</div>
)
: (
null
)
}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment