1
0
Fork 0

Keep chart item when switching dates

This commit is contained in:
Gregory Eremin 2015-03-16 23:04:10 +07:00
parent 2495b3e539
commit 58a9713bf2
2 changed files with 6 additions and 2 deletions

View File

@ -25,7 +25,9 @@ var BarChart = React.createClass({
componentWillReceiveProps: function(newProps) {
this.setState({
item: newProps.items[0],
item: (_.isEqual(newProps.items, this.props.items)
? this.state.item
: newProps.items[0]),
state: 'newProps'
}, this.fetchData);
},

View File

@ -38,7 +38,9 @@ var StackedAreaChart = React.createClass({
componentWillReceiveProps: function(newProps) {
this.setState({
item: newProps.items[0],
item: (_.isEqual(newProps.items, this.props.items)
? this.state.item
: newProps.items[0]),
state: 'newProps'
}, this.fetchData);
},