Last active
December 30, 2017 11:21
-
-
Save divyanshu013/3d496f6a6cc6b1dcb1656c4b3033e356 to your computer and use it in GitHub Desktop.
Topic component for GitXplore app
This file contains hidden or 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
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class Topic extends Component { | |
handleClick = () => { | |
this.props.toggleTopic(this.props.children); | |
} | |
render() { | |
return ( | |
<div className={`topic ${this.props.active ? 'active' : ''}`} onClick={this.handleClick}> | |
#{this.props.children} | |
</div> | |
); | |
} | |
} | |
Topic.propTypes = { | |
children: PropTypes.string, | |
active: PropTypes.bool, | |
toggleTopic: PropTypes.func, | |
}; | |
export default Topic; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment