Created
January 9, 2018 13:32
-
-
Save dmitryshelomanov/d1d13e6cd35ed1b714cb1929c7b80cf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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