Skip to content

Instantly share code, notes, and snippets.

@divyanshu013
Last active December 30, 2017 11:21
Show Gist options
  • Save divyanshu013/3d496f6a6cc6b1dcb1656c4b3033e356 to your computer and use it in GitHub Desktop.
Save divyanshu013/3d496f6a6cc6b1dcb1656c4b3033e356 to your computer and use it in GitHub Desktop.
Topic component for GitXplore app
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