Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.11.0-rc.3

- Changed `React.jsxKeyed(s)`, `ReactDOM.jsxKeyed(s)` having key as optional argument.

## 0.11.0-rc.2

- Fixed JSX PPX V3 backward compatibility.
Expand Down
16 changes: 8 additions & 8 deletions src/React.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions src/React.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ let component = Jsx.component

%%private(
@inline
let addKeyProp = (p: 'props, k: string): 'props =>
Obj.magic(Js.Obj.assign(Obj.magic(p), {"key": k}))
let addKeyProp = (~key: option<string>=?, p: 'props): 'props =>
switch key {
| Some(key) => Obj.magic(Js.Obj.assign(Obj.magic(p), {"key": key}))
| None => p
}
)

@module("react")
external createElement: (component<'props>, 'props) => element = "createElement"

let createElementWithKey = (component, props, key) =>
createElement(component, addKeyProp(props, key))
let createElementWithKey = (~key=?, component, props) =>
createElement(component, addKeyProp(~key?, props))

@module("react")
external cloneElement: (element, 'props) => element = "cloneElement"
Expand All @@ -36,20 +39,20 @@ 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) =>
createElementVariadic(component, addKeyProp(~key?, props), elements)

@module("react/jsx-runtime")
external jsxKeyed: (component<'props>, 'props, string) => element = "jsx"
external jsx: (component<'props>, 'props) => element = "jsx"

@module("react/jsx-runtime")
external jsx: (component<'props>, 'props) => element = "jsx"
external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsx"

@module("react/jsx-runtime")
external jsxs: (component<'props>, 'props) => element = "jsxs"

@module("react/jsx-runtime")
external jsxsKeyed: (component<'props>, 'props, string) => element = "jsxs"
external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs"

type fragmentProps<'children> = {children: 'children}

Expand Down Expand Up @@ -413,13 +416,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"
Expand Down
6 changes: 3 additions & 3 deletions src/ReactDOM.res
Original file line number Diff line number Diff line change
Expand Up @@ -1109,16 +1109,16 @@ external createDOMElementVariadic: (
external someElement: React.element => option<React.element> = "%identity"

@module("react/jsx-runtime")
external jsxKeyed: (string, JsxDOM.domProps, string) => Jsx.element = "jsx"
external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx"

@module("react/jsx-runtime")
external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx"
external jsxKeyed: (string, JsxDOM.domProps, ~key: string=?, @ignore unit) => Jsx.element = "jsx"

@module("react/jsx-runtime")
external jsxs: (string, JsxDOM.domProps) => Jsx.element = "jsxs"

@module("react/jsx-runtime")
external jsxsKeyed: (string, JsxDOM.domProps, string) => Jsx.element = "jsxs"
external jsxsKeyed: (string, JsxDOM.domProps, ~key: string=?, @ignore unit) => Jsx.element = "jsxs"

// Currently, not used by JSX ppx
@deprecated("Please use ReactDOM.createElement instead.")
Expand Down