error wrapper hoc

This commit is contained in:
tresabhi committed 2026-05-20 12:22:03 -05:00
1 parent ad78e45f1b
commit d3ab4bac51
2 files changed
+9 -4

No files matched your search

@@ -1,12 +1,14 @@
import type { ReactNode } from "react"; import type { ReactNode } from "react";
import { ErrorWrapper } from "../components/ErrorWrapper"; import { ErrorWrapper } from "../components/ErrorWrapper";
export function withErrorWrapper<Props extends {}>( export function withErrorWrapper<Props extends object>(
Component: (props: Props) => ReactNode, Component: (props: Props) => ReactNode,
) { ) {
return function (props: Props) { return function (props: Props) {
return (
<ErrorWrapper> <ErrorWrapper>
<Component {...props} /> <Component {...props} />
</ErrorWrapper>; </ErrorWrapper>
);
}; };
} }
@@ -1,6 +1,7 @@
import { Fragment, useMemo } from "react"; import { Fragment, useMemo } from "react";
import { api } from "../../../../api/dynamic"; import { api } from "../../../../api/dynamic";
import { TankopediaLoadout } from "../../../../components/TankopediaLoadout"; import { TankopediaLoadout } from "../../../../components/TankopediaLoadout";
import { withErrorWrapper } from "../../../../hocs/withErrorWrapper";
import { withLocale } from "../../../../hocs/withLocale"; import { withLocale } from "../../../../hocs/withLocale";
import { useAwait } from "../../../../hooks/useAwait"; import { useAwait } from "../../../../hooks/useAwait";
import { useCharacteristicRenderer } from "../../../../hooks/useCharacteristicRenderer"; import { useCharacteristicRenderer } from "../../../../hooks/useCharacteristicRenderer";
@@ -13,7 +14,8 @@ interface PageProps {
id: string; id: string;
} }
export const Page = withLocale(({ id }: PageProps) => { export const Page = withErrorWrapper(
withLocale<PageProps>(({ id }) => {
const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`); const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`);
Tankopedia.useInitialization(protagonistTank); Tankopedia.useInitialization(protagonistTank);
@@ -68,4 +70,5 @@ export const Page = withLocale(({ id }: PageProps) => {
})} })}
</> </>
); );
}); }),
);