@laigary.com~/labs/use-country-list-zh$
$ ./use-country-list-zh

中文的國家選單有個老問題:使用者的鍵盤是英文的。要選「美國」得先切輸入法, 或是在兩百多個選項裡捲。

這個 hook 讓中文清單吃英文查詢 —— 打 united 會同時命中美國與英國,打 jpJapan 都能找到日本。244 個國家,headless, UI 你自己畫。

// 搜尋(中文、英文、國碼都可以)
/
// sortBy
// 其他選項
// 244 個結果(顯示前 40 個,繼續打字縮小範圍)
// the call above
import { useCountryList } from "use-country-list-zh";

const { countries, query, setQuery, selectedCountry, setSelectedCountry, getDisplayText } =
  useCountryList({
    sortBy: "zh",
    showFlag: true,
    topList: ["TW","US","JP"],
  });

// query = "" → 244 個結果