Skip to content

Commit 5364e4a

Browse files
authored
Merge pull request #685 from fable-hub/v3.0_fix_singleTupleInput
Fix single tuple input for ReactComponent #644 + tests ✅
2 parents 72824fa + 2103864 commit 5364e4a

7 files changed

Lines changed: 307 additions & 140 deletions

File tree

src/Feliz.CompilerPlugins/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
## [Unreleased]
1818

19+
## 3.0.0-rc.3 - 2025-11-03
20+
21+
### 🐛 Fixed
22+
23+
- Correctly call single tuple inputs for ReactComponent #644 by @Freymaurer
24+
1925
## 3.0.0-rc.2 - 2025-11-03
2026

2127
### 🔄 Changed

src/Feliz.CompilerPlugins/ReactComponent.fs

Lines changed: 234 additions & 130 deletions
Large diffs are not rendered by default.

src/Feliz/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
## [Unreleased]
1818

19+
## 3.0.0-rc.6 - 2025-11-03
20+
21+
### 🐛 Fixed
22+
23+
- Correctly call single tuple inputs for ReactComponent #644 by @Freymaurer
24+
1925
## 3.0.0-rc.5 - 2025-11-07
2026

2127
### 🐛 Fixed

src/Feliz/Html.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ type Html =
787787
static member inline text (value: float) : ReactElement = unbox value
788788
static member inline text (value: int) : ReactElement = unbox value
789789
static member inline text (value: string) : ReactElement = unbox value
790+
static member inline text (value: bool) : ReactElement = unbox value
790791
static member inline text (value: System.Guid) : ReactElement = unbox (string value)
791792

792793
static member inline textf fmt = Printf.kprintf Html.text fmt

src/Feliz/Properties.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,9 @@ type prop =
17991799
/// Defines the text content of the element. Alias for `children [ Html.text value ]`
18001800
static member inline text (value: string) = PropHelper.mkAttr "children" [value]
18011801

1802+
/// Defines the text content of the element. Alias for `children [ Html.text value ]`
1803+
static member inline text (value: System.Guid) = PropHelper.mkAttr "children" [value.ToString()]
1804+
18021805
/// Defines the text content of the element. Alias for `children [ Html.text (sprintf ...) ]`
18031806
static member inline textf fmt = Printf.kprintf prop.text fmt
18041807

tests/Feliz/Basic.fs

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,38 @@ type Components =
137137
]
138138
]
139139
140-
// [<JSX.Component>]
141-
// static member ConditionalProperty(?condition: bool) =
142-
// Html.div [
143-
// if condition.IsSome && condition.Value then
144-
// prop.className "conditional-class"
145-
// prop.onClick (fun _ -> Browser.Dom.console.log("Div clicked!"))
146-
// prop.children [
147-
// Html.div "Hello, World!"
148-
// ]
149-
// ]
140+
[<ReactComponent>]
141+
static member SingleTupleInput1(testing: (int * string * System.Guid)) =
142+
let (a, b, c) = testing
143+
Html.div [
144+
Html.div [
145+
prop.testId "int"
146+
prop.text a
147+
]
148+
Html.div [
149+
prop.testId "string"
150+
prop.text b
151+
]
152+
Html.div [
153+
prop.testId "guid"
154+
prop.text c
155+
]
156+
]
157+
158+
[<ReactComponent>]
159+
static member SingleTupleInput2(notTestingInsteadSomethingElse: (int * string * System.Guid)) =
160+
let (a, b, c) = notTestingInsteadSomethingElse
161+
Html.div [
162+
Html.div [
163+
prop.testId "int"
164+
prop.text a
165+
]
166+
Html.div [
167+
prop.testId "string"
168+
prop.text b
169+
]
170+
Html.div [
171+
prop.testId "guid"
172+
prop.text c
173+
]
174+
]

tests/Feliz/Basic.test.fs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ describe "Simple createElement calls" <| fun _ ->
186186
let text = render.getByText "42.42"
187187
expect(text).toBeInTheDocument()
188188

189+
describe "Single Tuple Input Tests #644" <| fun _ ->
190+
191+
test "Component with single tuple input passes args correctly" <| fun _ ->
192+
let guid = System.Guid.NewGuid()
193+
RTL.render(
194+
Components.SingleTupleInput1((42, "Test", guid))
195+
) |> ignore
196+
197+
expect(RTL.screen.getByTestId "int").toHaveTextContent("42")
198+
expect(RTL.screen.getByTestId "string").toHaveTextContent("Test")
199+
expect(RTL.screen.getByTestId "guid").toHaveTextContent(guid.ToString())
200+
201+
test "Component with single tuple input passes args correctly and with different argument name" <| fun _ ->
202+
let guid = System.Guid.NewGuid()
203+
RTL.render(
204+
Components.SingleTupleInput2((42, "Test", guid))
205+
) |> ignore
206+
207+
expect(RTL.screen.getByTestId "int").toHaveTextContent("42")
208+
expect(RTL.screen.getByTestId "string").toHaveTextContent("Test")
209+
expect(RTL.screen.getByTestId "guid").toHaveTextContent(guid.ToString())
210+
189211
describe "Basic Tests" <| fun _ ->
190212

191213
test "Html elements can be rendered" <| fun _ ->

0 commit comments

Comments
 (0)