From 16787316018f488a2e1dcd47bb971efdaa47e2f1 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 13 Sep 2019 08:48:33 +0100 Subject: [PATCH] fix channel selector issues on publish page --- src/component/channelSelector/view.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 }); } }