Created
April 17, 2019 14:53
-
-
Save johnnykoo84/9cda01717e356d32e64759651e6080fb to your computer and use it in GitHub Desktop.
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
| 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