From 14fad134c8b5abfe391ede76d8098dd2e5bef863 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 20 Nov 2018 17:50:58 +0100 Subject: [PATCH] update state only when numbers have changed --- src/components/Repositories/Repository.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Repositories/Repository.jsx b/src/components/Repositories/Repository.jsx index b609546e..ebabc8e3 100644 --- a/src/components/Repositories/Repository.jsx +++ b/src/components/Repositories/Repository.jsx @@ -121,7 +121,15 @@ class Numbers extends PureComponent { }) const { forks, stars } = repo - this.setState({ forks, stars }) + + // update state only when numbers have changed + if (forks && forks !== this.props.forkCount) { + this.setState({ forks }) + } + + if (stars && stars !== this.props.stargazers.totalCount) { + this.setState({ stars }) + } } catch (error) { console.log(error) // eslint-disable-line no-console }