var React = require('react'); var TabView = React.createClass({ getDefaultProps: function() { return {tabPanes: []}; }, getInitialState: function() { return {activeTab: this.props.tabPanes[0]}; }, componentDidMount:function() { var userHash = window.location.hash; if(userHash) { userHash = userHash.split("#")[1]; this.props.tabPanes.forEach(function(pane) { if(pane.name === userHash) { this.setState({activeTab: pane}) } }.bind(this)); } }, handleChangeTab: function(tabPane) { this.setState({activeTab: tabPane}); }, render: function() { var tabNodes = this.props.tabPanes.map(function (tabPane) { return (
  • {tabPane.name}
  • ); }.bind(this)); return (
    {this.state.activeTab.content}
    ); } }); module.exports = TabView;