import React from 'react'; import { setPublishInChannel } from '../actions/index'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; class AnonymousOrChannelSelect extends React.Component { constructor (props) { super(props); this.toggleAnonymousPublish = this.toggleAnonymousPublish.bind(this); } toggleAnonymousPublish (event) { const value = event.target.value; if (value === 'anonymous') { this.props.onPublishInChannelChange(false); } else { this.props.onPublishInChannelChange(true); } } render () { return (
); } } const mapStateToProps = state => { return { publishInChannel: state.publishInChannel, }; }; const mapDispatchToProps = dispatch => { return { onPublishInChannelChange: (value) => { dispatch(setPublishInChannel(value)); }, }; } AnonymousOrChannelSelect.propTypes = { publishInChannel : PropTypes.bool.isRequired, onPublishInChannelChange: PropTypes.func.isRequired, }; export default connect(mapStateToProps, mapDispatchToProps)(AnonymousOrChannelSelect);