From 5e3a0e2cd735df383b60c8d42441fd8ad62c514c Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 4 Aug 2019 21:18:45 -0400 Subject: [PATCH] Fixed: Conditional Rendering on Page Jump Bar Co-Authored-By: Mark McDowall --- frontend/src/Components/Page/PageJumpBar.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/Components/Page/PageJumpBar.js b/frontend/src/Components/Page/PageJumpBar.js index 503cf04cd..41df52dfc 100644 --- a/frontend/src/Components/Page/PageJumpBar.js +++ b/frontend/src/Components/Page/PageJumpBar.js @@ -1,6 +1,6 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; -import React, { PureComponent } from 'react'; +import React, { Component } from 'react'; import dimensions from 'Styles/Variables/dimensions'; import Measure from 'Components/Measure'; import PageJumpBarItem from './PageJumpBarItem'; @@ -8,7 +8,7 @@ import styles from './PageJumpBar.css'; const ITEM_HEIGHT = parseInt(dimensions.jumpBarItemHeight); -class PageJumpBar extends PureComponent { +class PageJumpBar extends Component { // // Lifecycle @@ -26,6 +26,14 @@ class PageJumpBar extends PureComponent { this.computeVisibleItems(); } + shouldComponentUpdate(nextProps, nextState) { + return ( + nextProps.items !== this.props.items || + nextState.height !== this.state.height || + nextState.visibleItems !== this.state.visibleItems + ); + } + componentDidUpdate(prevProps, prevState) { if ( prevProps.items !== this.props.items ||