Skip to content

Instantly share code, notes, and snippets.

@johnnykoo84
Created April 17, 2019 14:53
Show Gist options
  • Save johnnykoo84/9cda01717e356d32e64759651e6080fb to your computer and use it in GitHub Desktop.
Save johnnykoo84/9cda01717e356d32e64759651e6080fb to your computer and use it in GitHub Desktop.
const Tabs = props => {
const { categories, currentCategory } = props;
return (
<>
<ul className="nav nav-pills nav-justified">
{categories.map(category => {
let btnClassName;
category.name === currentCategory
? (btnClassName = 'btn-primary')
: (btnClassName = 'btn-outline-primary');
return (
<li className="nav-item active p-1" key={category.id}>
<button
className={`btn ${btnClassName} btn-block`}
>
{category.name}
</button>
</li>
);
})}
</ul>
</>
);
};
class App extends Components {
// ...
render() {
const { currentPosts } = this.state;
return (
<div className="App">
<Tabs
categories={this.categories}
currentCategory={currentCategory}
/>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment