bradgarropy / use-countdown Goto Github PK
View Code? Open in Web Editor NEW⏳ useCountdown hook
Home Page: https://www.npmjs.com/package/@bradgarropy/use-countdown
License: MIT License
⏳ useCountdown hook
Home Page: https://www.npmjs.com/package/@bradgarropy/use-countdown
License: MIT License
Hello,
I was just wondering if it would be possible to add an ability to change the countdown duration times after useCountdown()
has been called.
For example, if you call reset()
, the countdown will restart but always for the duration of time specified on the initial useCountdown()
call (e.g., 5 seconds). The ability to change the duration of time on a reset()
would help me significantly with a project I'm working on.
Thank you for reading this,
SirIsaacNeutron
I have a play/pause button in my app that triggers the countdown, but I'd like the default behavior to be for the countdown to be paused until the user hits play.
I want to have the possibility to reset the countdown when a button is clicked. I think it could be relevant to restart the countdown without re-rendering the component.
I was wondering if it's possible to implement a freeze/stop for the timer. My use case is building a chess timer, and I need to be able to freeze the timer for each side when someone makes a move.
Hey there @bradgarropy 🤘 First of all, thanks so much for putting this together, it's been lovely to use!
Unfortunately, I just tested out resetting the timer with a specific time object and it keeps throwing this error: RangeError: Invalid time value
What's confusing is that the error is targeting the hook line, even though I'm making the reset()
call in another place entirely, via:
resendCodeCountdown.reset({ seconds: 30, format: "s 'sec'" })
Additionally here are some details on the versions I'm running this on:
@bradgarropy/[email protected]
[email protected]
[email protected]
Any ideas why this might not be working as expected? Thanks so much!
I'm trying to use this in my Vite + TypeScript + React project. I'm getting this error:
Error: Cannot find module 'tslib'
Require stack:
- /Users/work/ProgrammingProjects/focusqueue/node_modules/.pnpm/@bradgarropy[email protected][email protected]/node_modules/@bradgarropy/use-countdown/dist/index.js
❯ Object. node_modules/.pnpm/@bradgarropy[email protected][email protected]/node_modules/@bradgarropy/use-countdown/dist/index.js:3:15
I found the reference to tslib
in the compiled dist:
"use strict";
exports.__esModule = true;
var tslib_1 = require("tslib");
var countdown_1 = tslib_1.__importDefault(require("./countdown"));
exports["default"] = countdown_1["default"];
tslib_1.__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map
Looking in package.json
in this repo, it appears that tslib
is a dev dependency.
Should that be moved to the regular dependencies list, or should the build step be modified somehow to remove the reference to tslib
from the compiled distribution?
Hi,
Is there anyway to allow the timer keep going even after reaching 0?
So, when the timer hits 0, it starts counting up.
Hi Team,
Would you like to add a feature that will automatically count the days in between 2 dates?
Thanks
Venkata
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.