Skip to content

Commit

Permalink
Make children optional within TransProps (#728)
Browse files Browse the repository at this point in the history
* Make children optional within TransProps

* Add usage for Trans component with self-closing tag
  • Loading branch information
menthena authored and rosskevin committed Feb 11, 2019
1 parent 07c9ea9 commit e110d37
Show file tree
Hide file tree
Showing 2 changed files with 8 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 @@ -24,7 +24,7 @@ export function getInitialProps(): {
};

export interface TransProps extends Partial<i18next.WithT> {
children: React.ReactNode;
children?: React.ReactNode;
components?: React.ReactNode[];
count?: number;
defaults?: string;
Expand Down
7 changes: 7 additions & 0 deletions test/typescript/examples.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ function MyComponent() {
);
}

// Component using the Trans component without children (Self-closing)
function MyComponentWithoutChildren() {
return (
<Trans i18nKey="description.part1" />
);
}

// page uses the hook
function Page() {
const { t, i18n } = useTranslation();
Expand Down

0 comments on commit e110d37

Please sign in to comment.