Fix playslider

This commit is contained in:
Beto Dealmeida 2019-01-31 17:23:59 -08:00
parent adc9a6b495
commit a09348d0ec
1 changed files with 7 additions and 2 deletions

View File

@ -70,7 +70,7 @@ export default class CategoricalDeckGLContainer extends React.PureComponent {
*/
constructor(props) {
super(props);
this.state = this.getInitialStateFromProps(props);
this.state = this.getStateFromProps(props);
this.getLayers = this.getLayers.bind(this);
this.onValuesChange = this.onValuesChange.bind(this);
@ -78,6 +78,11 @@ export default class CategoricalDeckGLContainer extends React.PureComponent {
this.toggleCategory = this.toggleCategory.bind(this);
this.showSingleCategory = this.showSingleCategory.bind(this);
}
componentWillReceiveProps(nextProps) {
if (nextProps.payload.form_data !== this.state.formData) {
this.setState({ ...this.getStateFromProps(nextProps) });
}
}
onValuesChange(values) {
this.setState({
values: Array.isArray(values)
@ -88,7 +93,7 @@ export default class CategoricalDeckGLContainer extends React.PureComponent {
onViewportChange(viewport) {
this.setState({ viewport });
}
getInitialStateFromProps(props, state) {
getStateFromProps(props, state) {
const features = props.payload.data.features || [];
const timestamps = features.map(f => f.__timestamp);
const categories = getCategories(props.formData, features);