Many thanks for your component, this is exactly what I need. But, unfortunately, I'm unable to run it in a very simple way. The time is well displayed (10), but the timer doesn't start. Could you help me with this issue please?
Here is the code :
importReactfrom'react';import{StyleSheet,SafeAreaView,View,Text,Image}from'react-native';importTimerMachinefrom'react-timer-machine';importmomentfrom"moment";importmomentDurationFormatSetupfrom"moment-duration-format";momentDurationFormatSetup(moment);classCounterScreenextendsReact.Component{state={isTimerStarted: true,};constructor(props){super(props);}render(){return(<Text><TimerMachinetimeStart={10*1000}// start at 10 secondstimeEnd={20*1000}// end at 20 secondsstarted={this.state.isTimerStarted}paused={false}countdown={false}// use as stopwatchinterval={1000}// tick every 1 secondformatTimer={(time,ms)=>moment.duration(ms,'milliseconds').format('h:mm:ss')}onStart={time=>console.info(`Timer started: ${JSON.stringify(time)}`)}onStop={time=>console.info(`Timer stopped: ${JSON.stringify(time)}`)}onTick={time=>console.info(`Timer ticked: ${JSON.stringify(time)}`)}onPause={time=>console.info(`Timer paused: ${JSON.stringify(time)}`)}onResume={time=>console.info(`Timer resumed: ${JSON.stringify(time)}`)}onComplete={time=>console.info(`Timer completed: ${JSON.stringify(time)}`)}/></Text>);}}
Looks like my timer is pausing in background in a react-native app, which seems to be normal since Expo doesn't support background tasks.
You can work around it by keeping start and end time, maybe the timer itself can support this kind of behavior and by doing the diff rather than counting seconds?
Trying to install it on top of fresh create-react-app project.
Copy pasted the example code and it just shows 10 which is timeStart.
It never changes, callbacks onStart etc are never called.