Skip to content

Commit a4c31f8

Browse files
committed
add createElementWithKey
1 parent 5fd8b75 commit a4c31f8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/React.res

+6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ let component = Jsx.component
1717
@module("react")
1818
external createElement: (component<'props>, 'props) => element = "createElement"
1919

20+
let createElementWithKey = (component, props, key) =>
21+
createElement(component, Jsx.addKeyProp(props, key))
22+
2023
@module("react")
2124
external cloneElement: (element, 'props) => element = "cloneElement"
2225

2326
@variadic @module("react")
2427
external createElementVariadic: (component<'props>, 'props, array<element>) => element =
2528
"createElement"
2629

30+
let createDOMElementVariadicWithKey = (component, props, elements, key) =>
31+
createElementVariadic(component, Jsx.addKeyProp(props, key), elements)
32+
2733
@module("react/jsx-runtime")
2834
external jsxKeyed: (component<'props>, 'props, string) => element = "jsx"
2935

0 commit comments

Comments
 (0)