score:2

Accepted answer
class App extends React.Component {
  constructor(props) {
    super(props);

    // Initialise your state here.
    this.state = {
      tabList: tabList,
      currentTab: 1
    };

    // Bind your functions to this, avoiding scoping issues.
    this.changeTab = this.changeTab.bind(this);
  }

  // Use function property syntax
  changeTab(tab) {
    this.setState({ 
      currentTab: tab.id 
    });
  }

  render() {
    // deconstruct your state.
    const { currentTab, tabList } = this.state;

    return(
      <div>
          <Tabs currentTab={currentTab} tabList={tabList} changeTab={this.changeTab}/>
          <Content currentTab={currentTab} />
      </div>
    );
  }
}

score:3

constructor(props) {
    super(props);
    this.state = {
        tabList: tabList,
        currentTab: 1
    };
 }

Related Query

More Query from same tag