Created
February 14, 2018 22:06
-
-
Save jtomchak/20d0bfe3f2ca7bd5bf64efa185e06ac2 to your computer and use it in GitHub Desktop.
Tabs with onClick
This file contains hidden or 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
| class Tabs extends React.Component { | |
| state = { | |
| activeTabIndex: 0 | |
| }; | |
| handleTabClick = event => { | |
| this.setState({ | |
| tabActivated: 1 | |
| }); | |
| }; | |
| render() { | |
| const tabRectMarkup = this.props.data.map((country, index) => { | |
| return ( | |
| <div | |
| onClick={this.handleTabClick} | |
| className="Tab" | |
| style={styles.activeTab} | |
| > | |
| {country.name} | |
| </div> | |
| ); | |
| }); | |
| return ( | |
| <div className="Tabs"> | |
| {tabRectMarkup} | |
| <div className="TabPanel" style={styles.panel}> | |
| Country Description | |
| </div> | |
| </div> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment