Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Fix optional prop value example #618

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 32 additions & 0 deletions tests/ppx/react/expected/optionalPropValue.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Parens = {
type props<'id> = {key?: string, id?: 'id}
@react.component
let make = ({?id, _}: props<'id>) => {
ReactDOM.jsx(
"div",
{
id: ?{
let _ = ()
id->Option.map(x => x)
},
},
)
}
let make = {
let \"OptionalPropValue$Parens" = (props: props<_>) => make(props)
\"OptionalPropValue$Parens"
}
}

module WithoutParens = {
type props<'id> = {key?: string, id?: 'id}

@react.component
let make = ({?id, _}: props<'id>) => {
ReactDOM.jsx("div", {id: ?id->Option.map(x => x)})
}
let make = {
let \"OptionalPropValue$WithoutParens" = (props: props<_>) => make(props)
\"OptionalPropValue$WithoutParens"
}
}
18 changes: 18 additions & 0 deletions tests/ppx/react/optionalPropValue.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Parens = {
@react.component
let make = (~id=?) => {
<div
id=?{
let _ = ()
id->Option.map(x => x)
}
/>
}
}

module WithoutParens = {
@react.component
let make = (~id=?) => {
<div id=?{id->Option.map(x => x)} />
}
}