Countdown Timer for React and React Native
npm install react-deadline --save
import CountdownTimer from 'react-deadline';
...
render() {
return (
<CountdownTimer
endsAt={this.props.date}
onUpdate={timer => this.setState({timer: timer})>
{`${this.state.timer.hours}:${this.state.timer.minutes}:${this.state.timer.seconds}`}
</CountdownTimer>
)
}
endsAt
string - any string that moment js can parseonUpdate
function - called every 1000ms (1 second). Use this to set your state to the timer values.