mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
error wrapper hoc
This commit is contained in:
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) => {
|
|||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
}),
|
||||||
|
);
|
||||||
Reference in new issue
Block a user