createFlag関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 { createFlag } from "@johnmorrisdotca/hata/react-native";
定義
function createFlag(SvgXml: SvgXmlLike): (props: NativeFlagProps) => ReturnType<typeof createElement> | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
SvgXml | SvgXmlLike |
|
戻り値
(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).
例
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 viewfunction出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。