Created
January 31, 2018 13:52
-
-
Save SugarDarius/4125362d19dc65e56ba443bf0ed8aff6 to your computer and use it in GitHub Desktop.
Independent Dropdown Index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import IndependentDropdown from './independent-dropdown.jsx'; | |
export default class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
dropdowns: { | |
products: {display: false} | |
} | |
}; | |
} | |
displayDrowdown(id) { | |
const { dropdowns } = this.state; | |
dropdowns[id].display = !dropdowns[id].display; | |
this.setState({dropdowns: dropdowns}); | |
} | |
render() { | |
return ( | |
<div className='app'> | |
<header> | |
<div className='indepdent-dropdown-container-example'> | |
<a href='#' onClick={(e) => {e.preventDefault(); this.displayDrowdown('products')}}> | |
<span>Products</span> | |
</a> | |
<IndependentDropdown | |
id='dropdown' | |
display={this.state.dropdowns.products.display} | |
items={[...]} | |
onClickOutsideAction={(id) => {this.displayDrowdown(id)}} | |
/> | |
</div> | |
</header> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment