1.0.2 • Published 1 year ago

@cprecioso/react-use-clock v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

useClock

$ npm i -D @cprecioso/react-use-clock       # if you use npm
$ yarn add --dev @cprecioso/react-use-clock # if you use yarn

useCurrentTime

export const useCurrentTime: (ms?: number) => Date | null;

Returns the current time as a Date (or a null until effects fire).

Accepts an optional parameter, configuring how often you want the returned Date to update. Due to how browsers function, it is not a guaranteed target, but a best-effort one. The default value is 1000 (each second).

Calls to this hook with the same ms parameter will all update at the same time throughout your app, firing off the same timer. This allows you to use it freely and not have to worry about e.g. timestamps in different elements updating at different times.

1.0.2

1 year ago

1.0.1

1 year ago