Skip to content

Commit a3938ea

Browse files
committed
Fix addKeyProp to not mutate props object
1 parent fb232ec commit a3938ea

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/React.bs.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/React.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ type component<'props> = Jsx.component<'props>
1515
let component = Jsx.component
1616

1717
%%private(
18+
@val
19+
external propsWithKey: (@as(json`{}`) _, 'props, {"key": string}) => 'props = "Object.assign"
20+
1821
@inline
1922
let addKeyProp = (~key: option<string>=?, p: 'props): 'props =>
2023
switch key {
21-
| Some(key) => Obj.magic(Js.Obj.assign(Obj.magic(p), {"key": key}))
24+
| Some(key) => propsWithKey(p, {"key": key})
2225
| None => p
2326
}
2427
)

0 commit comments

Comments
 (0)