mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 23:07:26 +03:00
Used setState callback to ensure no race conditions occur
This commit is contained in:
parent
0b15fba640
commit
eef1946243
1 changed files with 4 additions and 10 deletions
|
@ -22,11 +22,11 @@ const MutedMessage = ({ children }) =>
|
||||||
|
|
||||||
export class ShortUrlsVisits extends React.Component {
|
export class ShortUrlsVisits extends React.Component {
|
||||||
state = { startDate: undefined, endDate: undefined };
|
state = { startDate: undefined, endDate: undefined };
|
||||||
loadVisits = (dates = {}) => {
|
loadVisits = () => {
|
||||||
const { match: { params } } = this.props;
|
const { match: { params } } = this.props;
|
||||||
this.props.getShortUrlVisits(params.shortCode, mapObjIndexed(
|
this.props.getShortUrlVisits(params.shortCode, mapObjIndexed(
|
||||||
value => value && value.format ? value.format('YYYY-MM-DD') : value,
|
value => value && value.format ? value.format('YYYY-MM-DD') : value,
|
||||||
{ ...this.state, ...dates }
|
this.state
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,19 +150,13 @@ export class ShortUrlsVisits extends React.Component {
|
||||||
<DateInput
|
<DateInput
|
||||||
selected={this.state.startDate}
|
selected={this.state.startDate}
|
||||||
placeholderText="Since"
|
placeholderText="Since"
|
||||||
onChange={date => {
|
onChange={date => this.setState({ startDate: date }, () => this.loadVisits())}
|
||||||
this.setState({ startDate: date });
|
|
||||||
this.loadVisits({ startDate: date });
|
|
||||||
}}
|
|
||||||
className="short-url-visits__date-input"
|
className="short-url-visits__date-input"
|
||||||
/>
|
/>
|
||||||
<DateInput
|
<DateInput
|
||||||
selected={this.state.endDate}
|
selected={this.state.endDate}
|
||||||
placeholderText="Until"
|
placeholderText="Until"
|
||||||
onChange={date => {
|
onChange={date => this.setState({ endDate: date }, () => this.loadVisits())}
|
||||||
this.setState({ endDate: date });
|
|
||||||
this.loadVisits({ endDate: date });
|
|
||||||
}}
|
|
||||||
className="short-url-visits__date-input"
|
className="short-url-visits__date-input"
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue