How to save current duration after reopening app
See original GitHub issueHello !
I wanted to know how to save the remaining time and displaying it back when launching app again.
Here is my current code :
<CountdownCircleTimer
isPlaying={true}
duration={duration}
size={280}
strokeWidth={20}
trailColor="#FFEEF6"
rotation="counterclockwise"
trailStrokeWidth={20}
initialRemainingTime={remainingTimeRef}
colors={'#EB589A'}
children={({remainingTime}) => {
const hours = Math.floor(remainingTime / 3600);
const minutes = Math.floor((remainingTime % 3600) / 60);
const seconds = remainingTime % 60;
remainingTimeRef.current = remainingTime;
return (
<Text
style={{
fontStyle: 'normal',
fontWeight: '500',
fontSize: 24,
textAlign: 'center',
letterSpacing: 2,
lineHeight: 32,
}}>
{hours}:{minutes}:{seconds}
</Text>
);
}}
onComplete={() => ({shouldRepeat: false}, setEndTitle(true))}
If anyone as a solution, it will help me !
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
How do I persist the current page/state after closing/reopening ...
You'd need to use Web Storage to save the state on the client. Your site would then read the stored state in and...
Read more >Quit and reopen an app on iPhone - Apple Support
To reopen the app, go to the Home Screen (or App Library), then tap the app. If quitting and reopening the app doesn't...
Read more >Save UI states - Android Developers
To reload data after a system-initiated process death in a ViewModel, use the SavedStateHandle API. Alternatively, if the data is related to the ......
Read more >Now, Today, IsToday, UTCNow, and UTCToday functions in ...
Preview the app by pressing F5, and then start the timer by clicking or tapping it. The label continually shows the current time,...
Read more >How to save and export files in Adobe Audition CC
To save changes to the current session file, choose File > Save. To save changes under a different filename, choose File > Save...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok sounds good. I will try saving it somewhere ! Thanks for you time and advice
When you kill the app then all local component state is gone. You will need to save the remaining time in some persistent place, like on the Web is local storage or DB.
The countdown should reflect the time passed while it was on the background and continue from where there but not the place where the countdown when in the background. If you want to keep the same time as the one when it went in the background you can simply pause it when going to background and start in again when active.