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 · /react-native

createFlagfunction

Make the native flag component from react-native-svg's SvgXml. The component draws the flag at the height of size (24 points by default) and the flag's proportions, or at width, with the place's name as its accessibility label. Make it once, at the top of a module.

Import it

import { createFlag } from "@johnmorrisdotca/hata/react-native";

Definition

function createFlag(SvgXml: SvgXmlLike): (props: NativeFlagProps) => ReturnType<typeof createElement> | null

Parameters

NameTypeDescription
SvgXmlSvgXmlLike

SvgXml from react-native-svg.

Returns

(props: NativeFlagProps) => ReturnType<typeof createElement> | null

The component: it gives a React element, or null when the package has no flag for it, or it is not loaded yet in React 18 (preloadFlags loads it first).

Examples

import { createElement } from "react";
import { createFlag } from "@johnmorrisdotca/hata/react-native";

const SvgXml = (props: { xml: string }) => createElement("svg", { dangerouslySetInnerHTML: { __html: props.xml } }); // react-native-svg's, in an app
const Flag = createFlag(SvgXml as never);
console.log(typeof Flag); // "function": <Flag code="JP" size="medium" /> in a view
function

What it prints (run when this page was built)

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