preloadFlagsfunction
Load flags before a render that cannot wait: a server render to a string, a static build, the first render on the client that must match it.
After it, cachedFlag and the bindings' components give the flag at once.
Import it
import { preloadFlags } from "@johnmorrisdotca/hata/bind";
Also exported from: @johnmorrisdotca/hata/react, @johnmorrisdotca/hata/vue, @johnmorrisdotca/hata/react-native
Definition
function preloadFlags(list: readonly FlagProps[]): Promise<void>
Parameters
| Name | Type | Description |
|---|---|---|
list | readonly FlagProps[] | The flags to load. |
Returns
Promise<void>
A promise that settles when every flag is loaded (a flag that has none is loaded as null).
Examples
import { cachedFlag, preloadFlags } from "@johnmorrisdotca/hata/bind";
await preloadFlags([{ code: "JP" }, { code: "CA", shape: "round" }]);
console.log(cachedFlag({ code: "JP" })?.name); // "Japan"JapanWhat it prints (run when this page was built)