-
Notifications
You must be signed in to change notification settings - Fork 44
Fix key prop type #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
5e09771
10f6400
9b0fe1b
adc1a55
2f48356
3f0f2e9
234798b
b8fa0f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,17 +14,13 @@ type component<'props> = Jsx.component<'props> | |
|
|
||
| let component = Jsx.component | ||
|
|
||
| %%private( | ||
| @inline | ||
| let addKeyProp = (p: 'props, k: string): 'props => | ||
| Obj.magic(Js.Obj.assign(Obj.magic(p), {"key": k})) | ||
| ) | ||
|
|
||
| @module("react") | ||
| external createElement: (component<'props>, 'props) => element = "createElement" | ||
|
|
||
| let createElementWithKey = (component, props, key) => | ||
| createElement(component, addKeyProp(props, key)) | ||
| let createElementWithKey = (~key=?, component, props) => { | ||
| let _ = Obj.magic(props)["key"] = key | ||
| createElement(component, props) | ||
| } | ||
|
|
||
| @module("react") | ||
| external cloneElement: (element, 'props) => element = "cloneElement" | ||
|
|
@@ -36,21 +32,35 @@ external isValidElement: 'a => bool = "isValidElement" | |
| external createElementVariadic: (component<'props>, 'props, array<element>) => element = | ||
| "createElement" | ||
|
|
||
| let createElementVariadicWithKey = (component, props, elements, key) => | ||
| createElementVariadic(component, addKeyProp(props, key), elements) | ||
| let createElementVariadicWithKey = (~key=?, component, props, elements) => { | ||
| let _ = Obj.magic(props)["key"] = key | ||
| createElementVariadic(component, props, elements) | ||
| } | ||
|
|
||
| @module("react/jsx-runtime") | ||
| external jsxKeyed: (component<'props>, 'props, string) => element = "jsx" | ||
| external jsxNotKeyed: (component<'props>, 'props) => element = "jsx" | ||
|
|
||
| @module("react/jsx-runtime") | ||
| external jsx: (component<'props>, 'props) => element = "jsx" | ||
| external jsxKeyed: (component<'props>, 'props, string) => element = "jsx" | ||
|
|
||
| let jsx = (~key=?, component, props) => | ||
|
||
| switch key { | ||
| | Some(key) => jsxKeyed(component, props, key) | ||
| | None => jsxNotKeyed(component, props) | ||
| } | ||
|
|
||
| @module("react/jsx-runtime") | ||
| external jsxs: (component<'props>, 'props) => element = "jsxs" | ||
| external jsxsNotKeyed: (component<'props>, 'props) => element = "jsxs" | ||
|
|
||
| @module("react/jsx-runtime") | ||
| external jsxsKeyed: (component<'props>, 'props, string) => element = "jsxs" | ||
|
|
||
| let jsxs = (~key=?, component, props) => | ||
| switch key { | ||
| | Some(key) => jsxsKeyed(component, props, key) | ||
| | None => jsxsNotKeyed(component, props) | ||
| } | ||
|
|
||
| type fragmentProps<'children> = {children: 'children} | ||
|
|
||
| @module("react/jsx-runtime") external jsxFragment: component<fragmentProps<'children>> = "Fragment" | ||
|
|
@@ -413,13 +423,13 @@ external useInsertionEffect7: ( | |
|
|
||
| @module("react") | ||
| external useSyncExternalStore: ( | ||
| ~subscribe: @uncurry ((unit => unit) => ((. unit) => unit)), | ||
| ~subscribe: @uncurry (unit => unit, . unit) => unit, | ||
| ~getSnapshot: @uncurry unit => 'state, | ||
| ) => 'state = "useSyncExternalStore" | ||
|
|
||
| @module("react") | ||
| external useSyncExternalStoreWithServerSnapshot: ( | ||
| ~subscribe: @uncurry ((unit => unit) => ((. unit) => unit)), | ||
| ~subscribe: @uncurry (unit => unit, . unit) => unit, | ||
| ~getSnapshot: @uncurry unit => 'state, | ||
| ~getServerSnapshot: @uncurry unit => 'state, | ||
| ) => 'state = "useSyncExternalStore" | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for missing changelog and tests too often 😅
Updated b8fa0f3