@@ -16,15 +16,18 @@ let component = Jsx.component
16
16
17
17
%%private (
18
18
@inline
19
- let addKeyProp = (p : 'props , k : string ): 'props =>
20
- Obj .magic (Js .Obj .assign (Obj .magic (p ), {"key" : k }))
19
+ let addKeyProp = (~key : option <string >= ?, p : 'props ): 'props =>
20
+ switch key {
21
+ | Some (key ) => Obj .magic (Js .Obj .assign (Obj .magic (p ), {"key" : key }))
22
+ | None => p
23
+ }
21
24
)
22
25
23
26
@module ("react" )
24
27
external createElement : (component <'props >, 'props ) => element = "createElement"
25
28
26
- let createElementWithKey = (component , props , key ) =>
27
- createElement (component , addKeyProp (props , key ))
29
+ let createElementWithKey = (~ key = ?, component , props ) =>
30
+ createElement (component , addKeyProp (~ key ?, props ))
28
31
29
32
@module ("react" )
30
33
external cloneElement : (element , 'props ) => element = "cloneElement"
@@ -36,20 +39,20 @@ external isValidElement: 'a => bool = "isValidElement"
36
39
external createElementVariadic : (component <'props >, 'props , array <element >) => element =
37
40
"createElement"
38
41
39
- let createElementVariadicWithKey = (component , props , elements , key ) =>
40
- createElementVariadic (component , addKeyProp (props , key ), elements )
42
+ let createElementVariadicWithKey = (~ key = ?, component , props , elements ) =>
43
+ createElementVariadic (component , addKeyProp (~ key ?, props ), elements )
41
44
42
45
@module ("react/jsx-runtime" )
43
- external jsxKeyed : (component <'props >, 'props , string ) => element = "jsx"
46
+ external jsx : (component <'props >, 'props ) => element = "jsx"
44
47
45
48
@module ("react/jsx-runtime" )
46
- external jsx : (component <'props >, 'props ) => element = "jsx"
49
+ external jsxKeyed : (component <'props >, 'props , ~ key : string = ?, @ ignore unit ) => element = "jsx"
47
50
48
51
@module ("react/jsx-runtime" )
49
52
external jsxs : (component <'props >, 'props ) => element = "jsxs"
50
53
51
54
@module ("react/jsx-runtime" )
52
- external jsxsKeyed : (component <'props >, 'props , string ) => element = "jsxs"
55
+ external jsxsKeyed : (component <'props >, 'props , ~ key : string = ?, @ ignore unit ) => element = "jsxs"
53
56
54
57
type fragmentProps <'children > = {children : 'children }
55
58
@@ -413,13 +416,13 @@ external useInsertionEffect7: (
413
416
414
417
@module ("react" )
415
418
external useSyncExternalStore : (
416
- ~subscribe : @uncurry (( unit => unit ) => (( . unit ) => unit )) ,
419
+ ~subscribe : @uncurry (unit => unit , . unit ) => unit ,
417
420
~getSnapshot : @uncurry unit => 'state ,
418
421
) => 'state = "useSyncExternalStore"
419
422
420
423
@module ("react" )
421
424
external useSyncExternalStoreWithServerSnapshot : (
422
- ~subscribe : @uncurry (( unit => unit ) => (( . unit ) => unit )) ,
425
+ ~subscribe : @uncurry (unit => unit , . unit ) => unit ,
423
426
~getSnapshot : @uncurry unit => 'state ,
424
427
~getServerSnapshot : @uncurry unit => 'state ,
425
428
) => 'state = "useSyncExternalStore"
0 commit comments