diff options
Diffstat (limited to 'vnext/src/components/Feeds.js')
-rw-r--r-- | vnext/src/components/Feeds.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js index 7b6713f6..626732f6 100644 --- a/vnext/src/components/Feeds.js +++ b/vnext/src/components/Feeds.js @@ -9,6 +9,7 @@ import Message from './Message'; import Spinner from './Spinner'; import { getMessages } from '../api'; +import { UserType } from './Types'; export function Discover(props) { const query = { @@ -69,16 +70,19 @@ class Feed extends React.Component { componentDidMount() { this.loadMessages(this.props.visitor.hash, this.props.location.search); } - componentWillReceiveProps(nextProps) { - if (this.props.location.search != nextProps.location.search - || this.props.visitor != nextProps.visitor) { - this.loadMessages(nextProps.visitor.hash, nextProps.location.search) + getSnapshotBeforeUpdate(prevProps) { + return (this.props.location.search != prevProps.location.search + || this.props.visitor != prevProps.visitor); + } + componentDidUpdate(prevProps, prevState, shouldReload) { + if (shouldReload) { + this.loadMessages(this.props.visitor.hash, this.props.location.search); } } loadMessages = (hash = '', filter = '') => { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; - this.setState({ msgs: [], loading: true }) + this.setState({ msgs: [], loading: true }); const filterParams = qs.parse(filter); let params = Object.assign({}, filterParams || {}, this.props.query.search || {}); let url = this.props.query.baseUrl; @@ -144,6 +148,10 @@ Tag.propTypes = { }; Feed.propTypes = { + authRequired: PropTypes.bool, + visitor: UserType, + history: ReactRouterPropTypes.history.isRequired, + location: ReactRouterPropTypes.location.isRequired, msgs: PropTypes.array, query: PropTypes.shape({ baseUrl: PropTypes.string.isRequired, |