Skip to content

Commit 3e8921a

Browse files
committed
exploring state and events - part 5
1 parent b2bf2d4 commit 3e8921a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

dropdown/src/dropdown.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ var ListItem = require('./list-item');
88

99
module.exports = React.createClass({
1010
handleClick: function() {
11-
alert('hello from dropdown');
11+
this.setState({open: !this.state.open});
12+
},
13+
getInitialState: function(){
14+
return { open: false }
1215
},
1316
render: function() {
1417
var list = this.props.items.map(function(item){
@@ -22,7 +25,7 @@ module.exports = React.createClass({
2225
title={this.props.title}
2326
subTitleClassName="caret"
2427
/>
25-
<ul>
28+
<ul className={"dropdown-menu " + (this.state.open ? "show" : "") }>
2629
{list}
2730
</ul>
2831
</div>

0 commit comments

Comments
 (0)