delay initial request until datepicker component bubbled up the correct period

This commit is contained in:
Danny 2018-05-09 10:55:56 +02:00
parent e73a205d26
commit 3c823e9351
3 changed files with 7 additions and 10 deletions

View File

@ -24,10 +24,6 @@ class CountWidget extends Component {
}
}
componentDidMount() {
this.fetchData();
}
componentWillReceiveProps(newProps, prevState) {
if(newProps.before == prevState.before && newProps.after == prevState.after) {
return;

View File

@ -31,9 +31,7 @@ class DatePicker extends Component {
before: 0,
after: 0,
}
}
componentDidMount() {
this.setTimeRange(this.state.period)
}

View File

@ -21,10 +21,6 @@ class Table extends Component {
}
}
componentDidMount() {
this.fetchRecords()
}
componentWillReceiveProps(newProps, prevState) {
if(newProps.before == prevState.before && newProps.after == prevState.after) {
return;
@ -40,9 +36,16 @@ class Table extends Component {
@bind
fetchRecords() {
this.setState({ loading: true });
let before = this.state.before;
let after = this.state.after;
Client.request(`${this.props.endpoint}?before=${this.state.before}&after=${this.state.after}&limit=${this.state.limit}`)
.then((d) => {
// request finished; check if timestamp range is still the one user wants to see
if( this.state.before != before || this.state.after != after ) {
return;
}
this.setState({
loading: false,
records: d,