我在我的应用程序中使用 react-i18nextI18nextProvider
和withNamespaces
.
export const App = () => (
<I18nextProvider i18n={i18n}>
<App />
</I18nextProvider>
);
export default withNamespaces()(ChildComponentOfApp);
但我不明白I18nextProvider
and的关系withNamespaces
。他们不传递道具之类的t
功能
提供者负责使用 react context api 将 props 传入的 i18next 实例向下传递给所有 withNamespaces hocs 或 NamespacesConsumer 渲染 prop。
是为什么工作?这是渲染道具withNamespaces
吗?
我知道那是 HOC,但在阅读 react-i18next 源代码之后甚至混淆withNamespaces
了这种关系。I18nextProvider
withNamespaces
有人可以解释一下吗?