Skip to content

Instantly share code, notes, and snippets.

@darklilium
Last active May 2, 2017 18:48
Show Gist options
  • Save darklilium/08f5a1ea92b00c6fac53cd560d6f031d to your computer and use it in GitHub Desktop.
Save darklilium/08f5a1ea92b00c6fac53cd560d6f031d to your computer and use it in GitHub Desktop.
React Tabs component
/*The tab component doesnt work too well when u try to render it.
https://github.com/reactjs/react-tabs
Thanks to : deepaksisodiya
"Removing the selectedIndex={0} is not a solution,
You need to set it by state, like
selectedIndex={this.state.selectedTab}
also initialise selectedTab state to your preferred tab.
then on onSelect={this._handleSelect} event of Tabs, set the selectedTab again.
*/
_handleSelect = (index, last) => {
console.log('Selected tab: ' + index + ', Last tab: ' + last);
this.setState({
selectedTab: index
});
};
// by doing this, on tab it will not move to another tab by click event :)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment