Skip to content

Instantly share code, notes, and snippets.

@egormerkushev
Created July 27, 2017 08:44
Show Gist options
  • Save egormerkushev/5b9dc93d7a1b39d2e998c63326820aa6 to your computer and use it in GitHub Desktop.
Save egormerkushev/5b9dc93d7a1b39d2e998c63326820aa6 to your computer and use it in GitHub Desktop.
import Timer from 'react-native-timer'
...
render() {
return (
...
<Text>Time left: {this.state.timeLeftText}</Text>
...
)
}
_startRenderTimer() {
Timer.setInterval(
this,
RenderTimerName,
this._renderTimerCycle.bind(this),
250) // 4 times per second
}
_renderTimerCycle() {
...
if (this.tmpTime !== fireIntervalString) {
this.tmpTime = fireIntervalString
this.setState({
timeLeftText: fireIntervalString,
})
}
...
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment