Update the navbar to a pure component
This commit is contained in:
parent
94468167cb
commit
7ff88c531f
@ -2,7 +2,7 @@ import React from 'react'
|
||||
import { Nav, Navbar, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'
|
||||
import { LinkContainer } from 'react-router-bootstrap'
|
||||
|
||||
export default class NavBar extends React.Component {
|
||||
export default class NavBar extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@ -11,25 +11,6 @@ export default class NavBar extends React.Component {
|
||||
displayShowsSearch: this.shouldDisplayShowsSearch(props.router),
|
||||
};
|
||||
}
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
if (nextProps.username !== this.props.username) {
|
||||
return true;
|
||||
}
|
||||
if (nextProps.torrentsCount !== this.props.torrentsCount) {
|
||||
return true;
|
||||
}
|
||||
if (nextState.displayMoviesSearch !== this.state.displayMoviesSearch) {
|
||||
return true;
|
||||
}
|
||||
if (nextState.displayShowsSearch !== this.state.displayShowsSearch) {
|
||||
return true;
|
||||
}
|
||||
if (nextState.userLoggedIn !== this.state.userLoggedIn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// Update the state based on the next props
|
||||
const shouldDisplayMoviesSearch = this.shouldDisplayMoviesSearch(nextProps.router);
|
||||
|
Loading…
x
Reference in New Issue
Block a user