1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

update state only when numbers have changed

This commit is contained in:
Matthias Kretschmann 2018-11-20 17:50:58 +01:00
parent 3f378e0a75
commit 14fad134c8
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -121,7 +121,15 @@ class Numbers extends PureComponent {
}) })
const { forks, stars } = repo 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) { } catch (error) {
console.log(error) // eslint-disable-line no-console console.log(error) // eslint-disable-line no-console
} }