File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -5,17 +5,28 @@ import { Platform } from "../Platform";
55
66import { 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} ;
You can’t perform that action at this time.
0 commit comments