isHydrating
Tells whether the code runs while hydrate() claims server markup.
Tells whether the code runs while hydrate() claims server markup. Read it at creation in a hook
whose first render must match the server, as useExternalStore does to read its server snapshot.
Import#
ts
import { isHydrating } from "@shadow-js/core/extend";
Signature#
ts
function isHydrating(): boolean
Returns#
True inside withHydration, false otherwise.
Examples#
ts
import { isHydrating } from "@shadow-js/core/extend";
function initialWidth(serverWidth: number): number {
return isHydrating() ? serverWidth : window.innerWidth;
}