Skip to content

Commit

Permalink
fix: typescript definition
Browse files Browse the repository at this point in the history
Wrap I18nContext value in an object
- add test for typedef
  • Loading branch information
seanplwong committed Aug 20, 2020
1 parent a24180f commit e5f663a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export interface I18nextProviderProps {
}

export const I18nextProvider: React.FunctionComponent<I18nextProviderProps>;
export const I18nContext: React.Context<i18n>;
export const I18nContext: React.Context<{ i18n: i18n }>;

export interface TranslationProps {
children: (
Expand Down
6 changes: 6 additions & 0 deletions test/typescript/context.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { useContext } from 'react';
import i18next from 'i18next';
import { I18nContext } from 'react-i18next';

i18next.reportNamespaces.addUsedNamespaces(['translation']);
i18next.reportNamespaces.getUsedNamespaces();

function ContextConsumer() {
const { i18n } = useContext(I18nContext);
}

0 comments on commit e5f663a

Please sign in to comment.