talalmajali / react-native-countdown-component

React Native CountDown
MIT License
264 stars 233 forks source link

Restart Timer on Button Press without changing Untill #85

Open usmanarif12 opened 3 years ago

usmanarif12 commented 3 years ago

Hello , could you guide me please on how to restart my timer on a button press with the same previous Untill value? i need it please help me

RaildoBarros commented 3 years ago

i need this too

Motazlubbad commented 3 years ago

me too

VSV6 commented 3 years ago

Same here!!

tekalpavan commented 3 years ago

Any update on this yet?

tekalpavan commented 3 years ago

You can do this by having a state variable to show and hide the component. This is a work around right now.

const [isCounterVisible, setIsCounterVisible] = useState(true);

const afterCountdownMethod = () => {
// do something here
setIsCounterVisible(false)
}

const someOtherMethodWhichEnablesCounter = () => {
setIsCounterVisible(true)
}

render (
                <CountDown
                    until={180}
                    onFinish={() => afterCountdownMethod}
                    size={20}
                    timeLabels={{ m: null, s: null }}
                    showSeparator={true}
                  />
)

This is restart the counter whenever it is mounted to the DOM