diff --git a/src/component/channelSelector/view.js b/src/component/channelSelector/view.js index 4584ce9..e5e8c29 100644 --- a/src/component/channelSelector/view.js +++ b/src/component/channelSelector/view.js @@ -30,11 +30,14 @@ export default class ChannelSelector extends React.PureComponent { if (!channels.length && !fetchingChannels) { fetchChannelListMine(); } + this.setState({ currentSelectedValue: channelName }); } - componentDidUpdate() { - const { channelName } = this.props; - if (this.state.currentSelectedValue !== channelName) { + componentWillReceiveProps(nextProps) { + const { channels: prevChannels = [], channelName } = this.props; + const { channels = [] } = nextProps; + + if (channels.length !== prevChannels.length && channelName !== this.state.currentSelectedValue) { this.setState({ currentSelectedValue: channelName }); } }