(0, _reactI18next.translate) 不是函数

2024-04-16

实际上,我是本地反应新手,在这里我尝试使用“react-i18next”将语言更改为阿拉伯语,但在执行时出现以下错误

ReactNativeJS ▶︎(0, _reactI18next.translate) 不是一个函数。 (在 '(0, _reactI18next.translate)('常见', { bindI18n: '语言已更改', 绑定存储:假 })', '(0, _reactI18next.translate)' 未定义)

这是我的代码

import React from 'react';
import AppNavigator from './src/controller/AppNavigator';
import { translate } from 'react-i18next';
// import i18n from './src/I18n/index';
console.reportErrorsAsExceptions = false;

const WrappedStack = ({ t }) => {
  return <AppNavigator screenProps={{ t }} />;
};
const ReloadAppOnLanguageChange = translate('common', {
  bindI18n: 'languageChanged',
  bindStore: false,
})(WrappedStack);

export default class App extends React.Component {
  render() {
    return (
      <ReloadAppOnLanguageChange/>
    );
  }
}

AppNavigator.js

import {
    createStackNavigator,
    createAppContainer,
} from 'react-navigation';
import SScreen from '../view/sScreen/SScreen';
import Login from '../view/login/Login';
import SignUp from '../view/signUp/SignUp';
import TabNavigation from '../controller/TabNavigation';
import ForgotPassword from '../view/forgotPassword/ForgotPassword';
import AddAppointment from '../view/addAppointment/AddAppointment';
import DrProfile from '../view/drProfile/DrProfile';
import PaymentHistory from '../view/paymentHistory/PaymentHistory';


const AppNavigator = createStackNavigator({
    SScreen: {
        screen: SScreen,
        navigationOptions: {
            header: null
        }
    },
    Login: {
        screen: Login,
        navigationOptions: {
            header: null
        }
    },
    SignUp: {
        screen: SignUp,
        navigationOptions: {
            header: null
        }
    },
    ForgotPassword: {
        screen: ForgotPassword,
        navigationOptions: {
            header: null
        }
    },
    TabNavigation: {
        screen: TabNavigation,
        navigationOptions: {
            header: null,
            title: "TabNavigation",
            headerStyle: {
                backgroundColor: '#B78FC3',
            },
            headerTintColor: 'white',
            headerTitleStyle: {
                fontWeight: 'bold',
            },
            headerTitleStyle: {
                flex: 1,
                textAlign: 'center',
            },
            headerLeft: null
        },
    },
    AddAppointment: {
        screen: AddAppointment,
        navigationOptions: {
            title: "Add An Appointment",
            headerStyle: {
                backgroundColor: '#B78FC3',
            },
            headerTintColor: 'white',
            headerTitleStyle: {
                fontWeight: 'bold',
            },
            headerTitleStyle: {
                flex: 1,
                textAlign: 'center',
            },
        },
    },
    DrProfile: {
        screen: DrProfile,
        navigationOptions: {
            headerStyle: {
                backgroundColor: '#B78FC3',
            },
            headerTintColor: 'white',
            headerTitleStyle: {
                fontWeight: 'bold',
            },
            headerTitleStyle: {
                flex: 1,
                textAlign: 'center',
            },
        },
    },
    PaymentHistory: {
        screen: PaymentHistory,
        navigationOptions: {
            title: "Payment History",
            headerStyle: {
                backgroundColor: '#B78FC3',
            },
            headerTintColor: 'white',
            headerTitleStyle: {
                fontWeight: 'bold',
            },
            headerTitleStyle: {
                flex: 1,
                textAlign: 'center',
            },
        },
    },
},
    { headerLayoutPreset: 'center' });


const App = createAppContainer(AppNavigator);
export default App; 

Use withTranslation()代替translate()HOC。 迁移文档中似乎缺少此内容。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

(0, _reactI18next.translate) 不是函数 的相关文章

随机推荐

  • 在 Visual Studio 2017 中删除垂直虚线缩进线

    我刚刚安装了 Visual Studio 2017 代码编辑器中出现了奇怪的垂直缩进标记 我怎样才能删除它们 附 我禁用了所有扩展 但这没有帮助 下面有一个选项Tools Options Text Editor called Show st
  • mvc3 路由设置为 id, id2 id3

    我有以下区域路线设置 context MapRoute Admin default3 Admin controller action id id2 id3 new action Index context MapRoute Admin de
  • capistrano,:db 角色,它的用途是什么?

    据我所知 卡皮斯特拉诺 db角色仅用于运行迁移 因此 在大多数情况下 它可能不应该实际上是运行数据库的服务器 为什么那里会有 ruby rails 堆栈 或者允许 ssh 登录 它只是您想要实际执行 Rails 迁移的任何服务器 并且只有标
  • 实现移动运动体

    Project 我正在制作一个简单的项目 其中我希望能够制作一个运动体并将其从 x 点移动到 y 点 创建运动体 似乎没有太多直接内容 我一直在关注一些关于实现运动体的不同教程 因为我找不到指定如何正确执行此操作的教程 Problem 这似
  • 如何使用数据列表比较并返回数据

    我是 Haskell 的新手 我正在努力寻找一种使用类成员变量来返回我正在寻找的成员变量的方法 我有这个数据 data Place Place name String north Float east Float rainfall Int
  • 奥尔森 时区 到 windows

    我需要在 Windows 中从奥尔森时区转换时区 使用PHP 我找到了这个http unicode org repos cldr trunk common supplemental windowsZones xml http unicode
  • 用于搜索 Google 云端硬盘的 Google Apps 脚本

    是否可以使用 Google Apps 脚本在 Google 云端硬盘中搜索文档和文件夹 谷歌已经取消了自己的文档 驱动器搜索小工具 因为它似乎依赖于 iGoogle 谷歌企业支持也承认了这一点 谢谢 我想你正在寻找搜索文件 https de
  • Unity使用Invoke在另一个脚本上调用方法

    我有两个脚本 其中一个重新启动场景 另一个是倒计时器 而不是在第一个脚本中调用重新启动场景方法 但是 它没有重新启动 即使没有错误 我也不明白为什么 重新启动场景的第一个脚本 using UnityEngine using UnityEng
  • 在编译时通过 constexpr 或模板函数获取多维 std::array 的大小

    我用的是三维std array 因为大小在编译时已知 但是 我注意到 size 函数不是静态的 因此 constexpr 模板函数无法访问 我已经找到了下面的演示示例 它估计一维的大小std array 然而 这不适用于二维或更多维度 有没
  • C# 中的并发集合

    我正在寻找一种方法来获得并发收集 in C 或者至少是一个支持的集合并发枚举器 现在我得到了InvalidOperationException当我正在迭代的集合发生变化时 我可以深度复制该集合并使用私人副本 但我想知道是否有更好的方法 代码
  • DisplayMemberPath 在 WPF 中不起作用

    我要显示CustomerList CustomerName财产项目ListBox using ItemsSource DisplayMemberPath仅限财产 但它不起作用 我不想使用DataContext或我的问题中的任何其他绑定 请帮
  • 实体框架 6 和集合

    我正在开发我的第一个实体框架应用程序 我正在使用 EF 版本 6 来自 Nuget 和 net 4 0 然而 我在一些对我来说似乎应该非常简单的事情上遇到了一些困难 我在互联网上发现了很多相互矛盾的建议和解决方案 但是在花了几天时间尝试解决
  • Firebase - Firestore - 使用 collection.add() 获取密钥

    我在使用 Firebase 的新 Firestore 时遇到问题 情况 我有一个collection room 我创建房间collection room add room 我正在尝试做的事情 我需要更新一个房间 为此 我使用 collect
  • 示例 urllib3 和 python 中的线程

    我正在尝试在简单线程中使用 urllib3 来获取多个 wiki 页面 该脚本将 为每个线程创建 1 个连接 我不明白为什么 并永远挂起 urllib3 和线程的任何提示 建议或简单示例 import threadpool from url
  • 将多行转换为一行,并以逗号作为分隔符[重复]

    这个问题在这里已经有答案了 如果我发出SELECT username FROM Users我得到这个结果 username Paul John Mary 但我真正需要的是one所有值均以逗号分隔的行 如下所示 Paul John Mary
  • 计算网格上两点之间恰好有“n”个节点的最短路径

    我在网格上定义了以下 3D 表面 pylab inline def muller potential x y use numpy False Muller potential Parameters x float np ndarray or
  • 实体框架 Fluent API 映射简单的一对多关系

    我有两张桌子 文档 Id DocumentTypeId 标题 详细信息 文档类型 ID 名称 描述 DocumentTypeId 是引用 DocumentTypes 表的外键 IE 所有文件都可以应该 有一个分配给它们的类型 我有两节课 p
  • 多人台球游戏物理模拟[关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 将邻接矩阵转换为 Cytoscape 的 Edgelist(csv 文件)

    我的 csv 文件中有一个大的 200 列 行 邻接矩阵 这详细说明了个体之间的互动 我想将此文件转换为边缘列表 可以手动完成 但需要大量时间 下面显示了一小部分数据 第一个单元格是空格 A B C A 0 0 1 B 0 0 1 C 1
  • (0, _reactI18next.translate) 不是函数

    实际上 我是本地反应新手 在这里我尝试使用 react i18next 将语言更改为阿拉伯语 但在执行时出现以下错误 ReactNativeJS 0 reactI18next translate 不是一个函数 在 0 reactI18nex