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
| Name | Type | Description |
|---|---|---|
SvgXml | SvgXmlLike |
|
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 viewfunctionWhat it prints (run when this page was built)