@@ -14,20 +14,13 @@ type component<'props> = Jsx.component<'props>
14
14
15
15
let component = Jsx .component
16
16
17
- %%private (
18
- @inline
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
- }
24
- )
25
-
26
17
@module ("react" )
27
18
external createElement : (component <'props >, 'props ) => element = "createElement"
28
19
29
- let createElementWithKey = (~key = ?, component , props ) =>
30
- createElement (component , addKeyProp (~key ?, props ))
20
+ let createElementWithKey = (~key = ?, component , props ) => {
21
+ let _ = Obj .magic (props )["key" ] = key
22
+ createElement (component , props )
23
+ }
31
24
32
25
@module ("react" )
33
26
external cloneElement : (element , 'props ) => element = "cloneElement"
@@ -39,8 +32,10 @@ external isValidElement: 'a => bool = "isValidElement"
39
32
external createElementVariadic : (component <'props >, 'props , array <element >) => element =
40
33
"createElement"
41
34
42
- let createElementVariadicWithKey = (~key = ?, component , props , elements ) =>
43
- createElementVariadic (component , addKeyProp (~key ?, props ), elements )
35
+ let createElementVariadicWithKey = (~key = ?, component , props , elements ) => {
36
+ let _ = Obj .magic (props )["key" ] = key
37
+ createElementVariadic (component , props , elements )
38
+ }
44
39
45
40
@module ("react/jsx-runtime" )
46
41
external jsxNotKeyed : (component <'props >, 'props ) => element = "jsx"
0 commit comments