小编Nic*_*ita的帖子

React Native 上的react-i18next 没有重载与此调用打字稿匹配

我正在尝试使用 typescript 4.1.2 在我的 React Native 应用程序中配置react-i18next 11.8.2:

i18n.use(initReactI18next).init({
  resources: {
    en,
    es,
  },
  lng: 'es',
  fallbackLng: 'es',
  interpolation: {
    escapeValue: false,
  },
});
Run Code Online (Sandbox Code Playgroud)

有两个资源文件(en,es)。

但我在使用 useTranslation 挂钩的 TFunction 接口中遇到打字稿错误:

const {t, i18n} = useTranslation(['SelectLanguage']);]

<StyledLabel>{t('SelectLanguage:title')}</StyledLabel>
Run Code Online (Sandbox Code Playgroud)

错误:

No overload matches this call.
  Overload 1 of 2, '(props: Pick<Pick<TextProps & RefAttributes<Text>, "key" | "ref" | "style" | "onLayout" | "testID" | "nativeID" | "accessible" | "accessibilityActions" | ... 35 more ... | "dataDetectorType"> & Partial<...>, "key" | ... 42 more ... …
Run Code Online (Sandbox Code Playgroud)

internationalization typescript react-native react-i18next react-native-ui-kitten

4
推荐指数
1
解决办法
6972
查看次数