resolveFlagfunction
A flag's inline SVG, loaded from its own module (flag(code, options) from /load) and kept, so that it is loaded once. The promise
is the same for the same flag, which is what a framework's suspending hook wants.
Import it
import { resolveFlag } from "@johnmorrisdotca/hata/bind";
Definition
function resolveFlag(props: FlagProps): Promise<BoundFlag | null>
Parameters
| Name | Type | Description |
|---|---|---|
props | FlagProps | The flag, as the element's attributes give it. |
Returns
Promise<BoundFlag | null>
A promise of the flag, or of null when the package has no flag for it (an unknown code, a restricted flag asked for without allowRestricted, a date with no flag).
Examples
import { resolveFlag } from "@johnmorrisdotca/hata/bind";
const japan = await resolveFlag({ code: "JP", label: "Japan" });
console.log(japan?.svg.startsWith("<svg")); // true
console.log(await resolveFlag({ code: "XX" })); // nulltrue
nullWhat it prints (run when this page was built)