From 7ff88c531f55eab1c1d8a291dc9b52f9fe150982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Sun, 21 May 2017 20:35:40 +0200 Subject: [PATCH] Update the navbar to a pure component --- src/public/js/components/navbar.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/public/js/components/navbar.js b/src/public/js/components/navbar.js index 8a7193e..56c1398 100644 --- a/src/public/js/components/navbar.js +++ b/src/public/js/components/navbar.js @@ -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);