Skip to content

Instantly share code, notes, and snippets.

@ovpv

ovpv/tab.js Secret

Created March 23, 2019 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovpv/839e834a0c880a1ff4a315eae17de8d0 to your computer and use it in GitHub Desktop.
Save ovpv/839e834a0c880a1ff4a315eae17de8d0 to your computer and use it in GitHub Desktop.
Tab Click Method
/* As you can see on click of the title i have added a function which executes the method
recieved through props from the accordion class, which return the active tab back to the accordion class */
class Tab extends React.Component{
render(){
return(
<div className="tab">
<div className="title flex jc-btwn" onClick={()=>{
this.props.handleclick(this.props.id)
}}>
<span>{this.props.title}</span>
<i className={this.props.active?"fas fa-minus" : "fas fa-plus"}></i>
</div>
<div className={this.props.active ? "content show" : "content hide"}>
{this.props.content}
</div>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment