Skip to content

Instantly share code, notes, and snippets.

@ShuvoHabib
Created May 13, 2017 16:39
Show Gist options
  • Save ShuvoHabib/fc3d622191f1d379462d97912abf8d59 to your computer and use it in GitHub Desktop.
Save ShuvoHabib/fc3d622191f1d379462d97912abf8d59 to your computer and use it in GitHub Desktop.
React JS Navigation Tab (The ES6 Way)
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