Skip to content

Commit

Permalink
Add missing file.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Jul 16, 2023
1 parent 1ac1d19 commit fd2baf9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ReactViews/workingWithTranslation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { i18n } from "i18next";
import React from "react";
import { useTranslation, TFunction } from "react-i18next";

// The normal withTranslation causes TypeScript to generate an invalid .d.ts file, for unknown reasons.
export default function workingWithTranslation<
Props extends { t?: TFunction; i18n?: i18n }
>(
WrappedComponent: React.ComponentType<Props>
): React.FC<Omit<Props, "t" | "i18n">> {
const WorkingWithTranslation: React.FC<Omit<Props, "t" | "i18n">> = (
props: Omit<Props, "t" | "i18n">
) => {
const { t, i18n } = useTranslation();
return <WrappedComponent {...(props as Props)} t={t} i18n={i18n} />;
};
return WorkingWithTranslation;
}

0 comments on commit fd2baf9

Please sign in to comment.