question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to save current duration after reopening app

See original GitHub issue

Hello !

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:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mattpilleulcommented, Jan 20, 2022

Ok sounds good. I will try saving it somewhere ! Thanks for you time and advice

1reaction
vydimitrovcommented, Jan 20, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found