Skip to content

Commit 4c8fd33

Browse files
fix(🌎): componentProps prop to WithSkiaWeb (#2662)
Co-authored-by: Santiago Topolansky <[email protected]>
1 parent 8f016e9 commit 4c8fd33

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

‎packages/skia/src/web/WithSkiaWeb.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,28 @@ import { Platform } from "../Platform";
55

66
import { LoadSkiaWeb } from "./LoadSkiaWeb";
77

8-
interface WithSkiaProps {
8+
type NonOptionalKeys<T> = {
9+
[k in keyof T]-?: undefined extends T[k] ? never : k;
10+
}[keyof T];
11+
12+
type WithSkiaProps<TProps> = {
913
fallback?: ComponentProps<typeof Suspense>["fallback"];
10-
getComponent: () => Promise<{ default: ComponentType }>;
14+
getComponent: () => Promise<{ default: ComponentType<TProps> }>;
1115
opts?: Parameters<typeof LoadSkiaWeb>[0];
12-
}
16+
} & (NonOptionalKeys<TProps> extends never
17+
? {
18+
componentProps?: TProps;
19+
}
20+
: {
21+
componentProps: TProps;
22+
});
1323

14-
export const WithSkiaWeb = ({
24+
export const WithSkiaWeb = <TProps extends object>({
1525
getComponent,
1626
fallback,
1727
opts,
18-
}: WithSkiaProps) => {
28+
componentProps,
29+
}: WithSkiaProps<TProps>) => {
1930
const Inner = useMemo(
2031
// TODO: investigate
2132
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -34,7 +45,7 @@ export const WithSkiaWeb = ({
3445
);
3546
return (
3647
<Suspense fallback={fallback ?? null}>
37-
<Inner />
48+
<Inner {...componentProps} />
3849
</Suspense>
3950
);
4051
};

0 commit comments

Comments
 (0)