Fixed tab bar not updating #3631 (#3653)

This commit is contained in:
Nicolas Gotchac 2016-11-28 16:13:02 +01:00 committed by Jaco Greeff
parent a7037f8e5b
commit 6be08d8ce4

View File

@ -19,6 +19,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { Toolbar, ToolbarGroup } from 'material-ui/Toolbar'; import { Toolbar, ToolbarGroup } from 'material-ui/Toolbar';
import { Tab as MUITab } from 'material-ui/Tabs'; import { Tab as MUITab } from 'material-ui/Tabs';
import { isEqual } from 'lodash';
import { Badge, Tooltip } from '../../../ui'; import { Badge, Tooltip } from '../../../ui';
@ -162,9 +163,13 @@ class TabBar extends Component {
} }
shouldComponentUpdate (nextProps, nextState) { shouldComponentUpdate (nextProps, nextState) {
const prevViews = this.props.views.map((v) => v.id).sort();
const nextViews = nextProps.views.map((v) => v.id).sort();
return (nextProps.hash !== this.props.hash) || return (nextProps.hash !== this.props.hash) ||
(nextProps.pending.length !== this.props.pending.length) || (nextProps.pending.length !== this.props.pending.length) ||
(nextState.activeViewId !== this.state.activeViewId); (nextState.activeViewId !== this.state.activeViewId) ||
(!isEqual(prevViews, nextViews));
} }
render () { render () {
@ -217,7 +222,7 @@ class TabBar extends Component {
active={ active } active={ active }
view={ view } view={ view }
onChange={ this.onChange } onChange={ this.onChange }
key={ index } key={ view.id }
pendings={ pending.length } pendings={ pending.length }
> >
{ body } { body }