useDailySeedfunction
Today's day and seed, which change on their own at midnight in timeZone
(UTC unless named): a page left open overnight moves to the new day's
puzzle without a reload.
On the server this reads the server's clock; a page rendered just before midnight and hydrated just after will show the new day once it hydrates.
Import it
import { useDailySeed } from "@johnmorrisdotca/tane/react";
Definition
function useDailySeed(timeZone?: string): DailySeed
Parameters
| Name | Type | Description |
|---|---|---|
timeZone (optional) | string | The IANA time-zone name; UTC when omitted. |
Returns
DailySeed
The current calendar day and its seed for the named zone.
Examples
import { useDailySeed } from "@johnmorrisdotca/tane/react";
import { createElement } from "react";
function DailyPuzzle() {
const today = useDailySeed("UTC");
return createElement("p", null, `${today.day}: ${today.seed}`);
}
console.log(createElement(DailyPuzzle));