Skip to content

Instantly share code, notes, and snippets.

@dmitryshelomanov
Created January 9, 2018 13:32
Show Gist options
  • Save dmitryshelomanov/d1d13e6cd35ed1b714cb1929c7b80cf4 to your computer and use it in GitHub Desktop.
Save dmitryshelomanov/d1d13e6cd35ed1b714cb1929c7b80cf4 to your computer and use it in GitHub Desktop.
export class RulesWrapTabs extends Component {
constructor(props) {
super(props)
this.state = {
activeIndex: 0,
}
}
render() {
return (
<Wrapper>
<ButtonWrapper>
{this.props.tabs.map((el, index) => (
<Button
key={index}
onClick={() => this.setState({ activeIndex: index })}
>
{el.title}
</Button>
))}
</ButtonWrapper>
<DataRender>
{this.props.tabs.map((el, index) => {
return React.cloneElement(el.component, {
isActive: this.state.activeIndex === index,
})
})}
</DataRender>
</Wrapper>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment