本文へ移動

Hata旗

国や地域の旗を読み込み、対応する表示の形を選び、絵ごとの資料・作者・ライセンスを保てます。

「旗(はた)」は、旗を表す日本語です。 名前について(英語)

目次

リファレンス · /react-native

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

引数

名前型説明
SvgXmlSvgXmlLike

SvgXml from react-native-svg.

戻り値

(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 view
function

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/hata 1.31.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。