Fix bug with sign in/out triggering updates

This commit is contained in:
Nicholas Zuber 2018-11-05 00:19:51 -05:00
parent e1a18b057e
commit 771dbff2ac

View File

@ -65,11 +65,15 @@ class NotificationsProvider extends React.Component {
}
shouldComponentUpdate (nextProps, nextState) {
// Update if our state changes
// Update if our state changes.
if ((this.state.loading !== nextState.loading) ||
(this.state.error !== nextState.error)) {
return true;
}
// Update if the token changes at all (sign in & sign out).
if (this.props.token !== nextProps.token) {
return true;
}
// Only update if our notifications prop changes.
// All other props "changing" should NOT trigger a rerender.
return this.props.notifications !== nextProps.notifications;