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";
5
5
6
6
import { LoadSkiaWeb } from "./LoadSkiaWeb" ;
7
7
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 > = {
9
13
fallback ?: ComponentProps < typeof Suspense > [ "fallback" ] ;
10
- getComponent : ( ) => Promise < { default : ComponentType } > ;
14
+ getComponent : ( ) => Promise < { default : ComponentType < TProps > } > ;
11
15
opts ?: Parameters < typeof LoadSkiaWeb > [ 0 ] ;
12
- }
16
+ } & ( NonOptionalKeys < TProps > extends never
17
+ ? {
18
+ componentProps ?: TProps ;
19
+ }
20
+ : {
21
+ componentProps : TProps ;
22
+ } ) ;
13
23
14
- export const WithSkiaWeb = ( {
24
+ export const WithSkiaWeb = < TProps extends object > ( {
15
25
getComponent,
16
26
fallback,
17
27
opts,
18
- } : WithSkiaProps ) => {
28
+ componentProps,
29
+ } : WithSkiaProps < TProps > ) => {
19
30
const Inner = useMemo (
20
31
// TODO: investigate
21
32
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -34,7 +45,7 @@ export const WithSkiaWeb = ({
34
45
) ;
35
46
return (
36
47
< Suspense fallback = { fallback ?? null } >
37
- < Inner />
48
+ < Inner { ... componentProps } />
38
49
</ Suspense >
39
50
) ;
40
51
} ;
You can’t perform that action at this time.
0 commit comments