Removing componentWillReceiveProps from base views

This commit is contained in:
James Barnsley
2020-03-11 20:40:20 +13:00
parent b988cf27f8
commit 3e56a3f873
10 changed files with 239 additions and 168 deletions

View File

@ -28,15 +28,25 @@ class User extends React.Component {
this.props.coreActions.loadUserPlaylists(this.props.uri);
}
componentWillReceiveProps(nextProps) {
if (nextProps.uri != this.props.uri) {
this.props.coreActions.loadUser(nextProps.uri);
this.props.coreActions.loadUserPlaylists(this.props.uri);
componentDidUpdate = ({
uri: prevUri,
user: prevUser,
}) => {
const {
uri,
user,
coreActions: {
loadUser,
loadUserPlaylists,
},
} = this.props;
if (prevUri !== uri) {
loadUser(uri);
loadUserPlaylists(uri);
}
if (!this.props.user && nextProps.user) {
this.setWindowTitle(nextProps.user);
}
if (!prevUser && user) this.setWindowTitle(user);
}
setWindowTitle(user = this.props.user) {