Created
May 13, 2017 16:39
-
-
Save ShuvoHabib/fc3d622191f1d379462d97912abf8d59 to your computer and use it in GitHub Desktop.
React JS Navigation Tab (The ES6 Way)
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 './App.css'; | |
class App extends Component { | |
state = { | |
isSelected: 'All', | |
}; | |
handleClick = (lang) => { | |
this.setState({isSelected: lang}); | |
}; | |
render() { | |
const language = ['All', 'JavaScript', 'Java', 'Php', 'Ruby']; | |
return ( | |
<div className="App"> | |
<ul className="lang-nav"> | |
{language.map((lang)=> | |
<li | |
style={lang === this.state.isSelected ? {color: '#d0021b'} : null} | |
className="nav-item" | |
onClick={this.handleClick.bind(null, lang)} | |
key={lang}> | |
{lang} | |
</li> | |
)} | |
</ul> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment