1

I'm trying to build a tab system with my basic react knowledge. To use the tab system you'd do something like this.

<Tabs onChange={this.handleTabChange}>
    <Tab id="home" title="Home">
    ...
</Tabs>

The Tabs component will render it's childern with {this.props.childern}

The Tab component needs to communicate to the outer Tabs component that it has been clicked and the outer component keeps track of "currentTab" in it's state.

If I were hard coding the Tabs and Tab components I could pass props from parent to child but as these components are going to be used repeatedly and are "dynamic" in the sense that they could comtain any childern I don't know where to begin wiring them up together.

Any help would really be appreciated.

jonhobbs
  • 26,684
  • 35
  • 115
  • 170
  • So, do you want to render n Tab components inside the Tabs component and when some Tab component receives a click, you want tell the Tabs component which Tab component got the clicked, right? – krionz Jul 28 '18 at 16:26
  • Yes, somebody pointed me in the direction of a similar question I hadn't found which appears to contain the answer. Thanks. – jonhobbs Jul 28 '18 at 16:30

0 Answers0