首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试导入错误:'withTranslation‘未从'react-i18next’中导出

尝试导入错误:'withTranslation‘未从'react-i18next’中导出
EN

Stack Overflow用户
提问于 2019-07-18 18:11:09
回答 1查看 3.2K关注 0票数 3

我刚开始使用React nad,我想导出一个组件,但我收到一个'withTranslation‘错误

我的代码摘要(版本:“i18next”:"^17.0.6","react-i18next":"^9.0.10",):

代码语言:javascript
复制
import React, {Component} from 'react';

import { translate } from 'react-i18next';
//version: "i18next": "^17.0.6","react-i18next": "^9.0.10",

//..........
//.............
class FromAlumno extends Component {
//................
//.....................
}

export default withTranslation("translation")(FromAlumno);
EN

回答 1

Stack Overflow用户

发布于 2019-07-18 19:13:22

问题不在于组件中的导出,而在于您没有从react-i18next导入withTranslation。只需将您的导入切换为以下内容:

代码语言:javascript
复制
import { withTranslation } from 'react-i18next';

我也建议在这里发帖之前先阅读react-i18next的文档。

https://react.i18next.com/latest/withtranslation-hoc

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57092126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档