Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

Reference · /bind

cachedFlagfunction

The flag, if it is already loaded: what a component draws at once, on a server or in a static build, with no waiting.

Import it

import { cachedFlag } from "@johnmorrisdotca/hata/bind";

Definition

function cachedFlag(props: FlagProps): BoundFlag | null | undefined

Parameters

NameTypeDescription
propsFlagProps

The flag, as the element's attributes give it.

Returns

BoundFlag | null | undefined

The flag; null where it was loaded and there is none; undefined where it is not loaded yet (call resolveFlag or preloadFlags).

Examples

import { cachedFlag, preloadFlags } from "@johnmorrisdotca/hata/bind";

console.log(cachedFlag({ code: "FR" }));  // undefined: not loaded yet
await preloadFlags([{ code: "FR" }]);
console.log(cachedFlag({ code: "FR" })?.aspect); // 1.5
undefined
1.5

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.31.0.