Skip to content

Instantly share code, notes, and snippets.

@jtomchak
Created February 14, 2018 22:06
Show Gist options
  • Select an option

  • Save jtomchak/20d0bfe3f2ca7bd5bf64efa185e06ac2 to your computer and use it in GitHub Desktop.

Select an option

Save jtomchak/20d0bfe3f2ca7bd5bf64efa185e06ac2 to your computer and use it in GitHub Desktop.
Tabs with onClick
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