The Countdown "STOPPED" when passing variables to the "date" prop.
See original GitHub issueI have a component looks like this:
function PracticeInfo({ totalQuestion, timeTest }) {
return (
<Grid.Row verticalAlign="middle">
<Grid.Column width={2} textAlign="center">
<p>
<span className="font-semibold text-xl">
<Countdown
daysInHours
date={Date.now() + timeTest * 60000}
/>
</span>
</p>
</Grid.Column>
<Grid.Column width={12} textAlign="center">
<p>
Total:{' '}
<span className="font-semibold">{totalQuestion}</span>
</p>
<Progress value="3" total={totalQuestion} indicating progress="ratio" />
</Grid.Column>
<Grid.Column width={2} textAlign="center">
<Button color="green" inverted>
Submit
</Button>
</Grid.Column>
</Grid.Row>
);
}
As you can see, I tend to use the timeTest
prop passing to the date
prop of Countdown component. But it stuck at the beginning (as the status “STOPPED”). Mapping the prop to other variables didn’t work also.
But if I passing number into it, it’s work fine. Eg: Date.now() + 60 * 60000
Please help!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Unable to pass props correctly to react-countdown component
I am using the package react-countdown and I am hoping to pass in a prop and use that prop as the initial state...
Read more >A customizable countdown component for React. - GitHub
onPause. onPause is a callback and triggered every time the countdown is paused. It receives a time delta object as the first argument....
Read more >How to Create a Countdown Timer with React Hooks
In this tutorial, you will create a countdown timer using React hooks to update state and manage side effects in a React component....
Read more >How to create a countdown timer using React Hooks
It displays each of the values(days, hours, minutes, and seconds) using a component called DateTimeDisplay that we create now. But notice the ...
Read more >Bento Date Countdown | bentojs.dev
Specifies whether to stop the timer when it reaches 0 seconds. The value can be set to stop (default) to indicate the timer...
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, 0 would make it stop (complete) immediately in its current implementation. I’m still contemplating whether it’s better to also restart the countdown again when a date in the future is provided in such cases, but it’s not there right now.
What you could do in the meantime is to pass the date as a
key
which would also restart the countdown whenever this key/date changes, but on a React component level. Alternatively, you could use the API to restart it again whenever/wherever you changetimeTest
.I tried the API and it’s working now. Thanks for your help.