From 7e27ceb88515118ea5f2a921c20b4004875c7097 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 4 Mar 2019 18:19:50 +0100 Subject: [PATCH] Ensured same timestamp is used when generating memoization ID after mounting the component --- src/visits/ShortUrlVisits.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/visits/ShortUrlVisits.js b/src/visits/ShortUrlVisits.js index cb064ee2..f7979d19 100644 --- a/src/visits/ShortUrlVisits.js +++ b/src/visits/ShortUrlVisits.js @@ -36,8 +36,7 @@ const ShortUrlVisits = ({ processStatsFromVisits }) => class ShortUrlVisits exte const { startDate, endDate } = dates; // While the "page" is loaded, use the timestamp + filtering dates as memoization IDs for stats calcs - this.memoizationId = `${new Date().getTime()}_${shortCode}_${startDate}_${endDate}`; - + this.memoizationId = `${this.timeWhenMounted}_${shortCode}_${startDate}_${endDate}`; getShortUrlVisits(shortCode, dates); }; @@ -45,6 +44,7 @@ const ShortUrlVisits = ({ processStatsFromVisits }) => class ShortUrlVisits exte const { match: { params }, getShortUrlDetail } = this.props; const { shortCode } = params; + this.timeWhenMounted = new Date().getTime(); this.loadVisits(); getShortUrlDetail(shortCode); } @@ -137,7 +137,7 @@ const ShortUrlVisits = ({ processStatsFromVisits }) => class ShortUrlVisits exte placeholderText="Since" isClearable maxDate={this.state.endDate} - onChange={(date) => this.setState({ startDate: date }, () => this.loadVisits())} + onChange={(date) => this.setState({ startDate: date }, this.loadVisits)} />
@@ -147,7 +147,7 @@ const ShortUrlVisits = ({ processStatsFromVisits }) => class ShortUrlVisits exte placeholderText="Until" isClearable minDate={this.state.startDate} - onChange={(date) => this.setState({ endDate: date }, () => this.loadVisits())} + onChange={(date) => this.setState({ endDate: date }, this.loadVisits)} />