import React from 'react'; import PropTypes from 'prop-types'; import ChannelLoginForm from '../containers/ChannelLoginForm.jsx'; import ChannelCreateForm from '../containers/ChannelCreateForm.jsx'; import { connect } from 'react-redux'; const LOGIN = 'login'; const CREATE = 'create'; class ChannelSelector extends React.Component { constructor (props) { super(props); this.state = { optionState: LOGIN, }; this.handleSelection = this.handleSelection.bind(this); this.selectOption = this.selectOption.bind(this); } componentWillMount () { console.log('ChannelSelector will mount'); if (this.props.loggedInChannelName) { this.selectOption(this.props.loggedInChannelName); } } componentWillReceiveProps ({ loggedInChannelName }) { if (loggedInChannelName) { this.selectOption(loggedInChannelName); } } handleSelection (event) { const selectedOption = event.target.selectedOptions[0].value; this.selectOption(selectedOption); } selectOption (option) { this.setState({optionState: option}); } render () { return (
{this.props.channelError}