From f62afd8a08d6e5dfdba7eb62d54655bc634e211c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 6 Jul 2018 01:48:09 +0300 Subject: Update deprecated React API --- vnext/src/components/Feeds.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'vnext/src') 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, -- cgit v1.2.3