Skip to content

Instantly share code, notes, and snippets.

@reggie3
Created July 13, 2017 06:25
Show Gist options
  • Save reggie3/1b4d4b8a52ec83a0c248cfdca0506b4e to your computer and use it in GitHub Desktop.
Save reggie3/1b4d4b8a52ec83a0c248cfdca0506b4e to your computer and use it in GitHub Desktop.
componentWillReceiveProps(nextProps) {
if (nextProps.location.distanceAverage < 10) {
this.setState({ loopSpeed: 10 });
}
else if (nextProps.location.distanceAverage < 100) {
this.setState({ loopSpeed: 100 });
}
else if (nextProps.location.distanceAverage < 1000) {
this.setState({ loopSpeed: 500 });
}
else if (nextProps.location.distanceAverage < 5000) {
this.setState({ loopSpeed: 1000 });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment