【发布时间】:2019-08-16 12:04:48
【问题描述】:
我在我的应用程序中使用 I18nextProvider 和 withNamespaces 来 react-i18next。
export const App = () => (
<I18nextProvider i18n={i18n}>
<App />
</I18nextProvider>
);
export default withNamespaces()(ChildComponentOfApp);
但我不明白I18nextProvider 和withNamespaces 的关系。他们没有传递像t函数这样的道具
provider 负责将 props 传入的 i18next 实例向下传递给所有 withNamespaces hocs 或 NamespacesConsumer 使用 react context api 的渲染 prop。
是为什么工作?这是withNamespaces 中的渲染道具吗?
我知道withNamespaces 是HOC,但即使在阅读react-i18next 源代码之后,也会混淆I18nextProvider 和withNamespaces 之间的这种关系。
谁能解释一下?
【问题讨论】:
标签: reactjs react-i18next