Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing I18nextProvider interface to typings #721

Merged
merged 4 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export function withTranslation(
component: React.ComponentType<P>,
) => React.ComponentType<Omit<P, keyof WithTranslation>>;

export interface I18nextProviderProps {
i18n: i18next.i18n;
}

export const I18nextProvider: React.FunctionComponent<I18nextProviderProps>;

export interface TranslationProps {
children: (
t: i18next.TFunction,
Expand Down
31 changes: 31 additions & 0 deletions test/typescript/I18nextProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import i18n from 'i18next';
import * as React from 'react';
import { I18nextProvider, initReactI18next } from 'react-i18next';

i18n.use(initReactI18next).init({
fallbackLng: 'en',

// have a common namespace used around the full app
ns: ['translations'],
defaultNS: 'translations',

debug: true,

interpolation: {
escapeValue: false, // not needed for react!!
},

react: {
wait: true,
},
});

function test() {
return (
<React.Suspense fallback={<p>Loading</p>}>
<I18nextProvider i18n={i18n}>
<h1>Foo</h1>
</I18nextProvider>
</React.Suspense>
);
}