Skip to content

Commit 62694ec

Browse files
committed
Fix props aliasing issue (inner let props) 🐛
1 parent 8632247 commit 62694ec

5 files changed

Lines changed: 46 additions & 10 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.6 - 2025-11-21
20+
21+
### 🐛 Fixed
22+
23+
- Fix `props` aliasing issue. A `let props` inside the react component also created duplication issues (by @Freymaurer)
24+
1925
## 3.0.0-rc.5 - 2025-11-21
2026

2127
### 🐛 Fixed

src/Feliz.CompilerPlugins/ReactComponent.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ type ReactComponentAttribute(?exportDefault: bool, ?import: string, ?from: strin
401401
|> List.unzip
402402
let type_ =
403403
Fable.Type.AnonymousRecordType(Array.ofList fieldNames, genericArgs, false)
404-
let mutable propsName = "props"
404+
let mutable propsName = "$props"
405405
while fieldNames |> List.contains propsName do
406406
propsName <- propsName + "_"
407407

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.12 - 2025-11-21
20+
21+
### 🐛 Fixed
22+
23+
- Fix `props` aliasing issue. A `let props` inside the react component also created duplication issues (by @Freymaurer)
24+
1925
## 3.0.0-rc.11 - 2025-11-21
2026

2127
### 🐛 Fixed

tests/Feliz/Basic.fs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,40 @@ type Components =
172172
]
173173
]
174174
175+
176+
module PropsAliasingTesting =
177+
178+
[<ReactComponent>]
179+
let private PropsAliasingInner(props: IReactProperty list, test: string) =
180+
Html.div [
181+
yield! props
182+
prop.children [
183+
Html.h1 "Welcome to the Fable Playground!"
184+
Html.p "This is a simple playground for experimenting with Fable and Feliz."
185+
]
186+
]
187+
175188
[<ReactComponent>]
176-
static member private PropsAliasingInner(props: IReactProperty list, test: string) =
189+
let ArgsPropsAliasing(props: IReactProperty list) =
177190
Html.div [
178-
for prop in props do
179-
prop
191+
yield! props
180192
prop.children [
193+
PropsAliasingInner(props, "test")
181194
Html.h1 "Welcome to the Fable Playground!"
182195
Html.p "This is a simple playground for experimenting with Fable and Feliz."
183196
]
184197
]
185198
186199
[<ReactComponent>]
187-
static member PropsAliasing(props: IReactProperty list) =
200+
let InnerLetBindingPropsAliasing(test: string, counter: int) =
201+
202+
let props =
203+
[ prop.testId "props-aliasing"
204+
prop.id "props-aliasing"
205+
prop.style [ style.backgroundColor "lightblue" ] ]
188206
Html.div [
189-
for prop in props do
190-
prop
207+
yield! props
191208
prop.children [
192-
Components.PropsAliasingInner(props, "test")
193209
Html.h1 "Welcome to the Fable Playground!"
194210
Html.p "This is a simple playground for experimenting with Fable and Feliz."
195211
]

tests/Feliz/Basic.test.fs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,20 @@ describe "Record Type Input Tests #606, #603" <| fun _ ->
247247

248248
describe "Props Aliasing Tests #687" <| fun _ ->
249249

250-
test "Component with arg called 'props' must alias main input to 'props_'" <| fun _ ->
250+
test "Component with input arg called props should be correctly aliased" <| fun _ ->
251251
RTL.render(
252-
Components.PropsAliasing([prop.style [ style.padding 20; style.backgroundColor.blanchedAlmond ]; prop.testId "main-component"])
252+
PropsAliasingTesting.ArgsPropsAliasing([prop.style [ style.padding 20; style.backgroundColor.blanchedAlmond ]; prop.testId "main-component"])
253253
) |> ignore
254254

255255
let components = RTL.screen.getAllByTestId "main-component"
256256
expect(components).toHaveLength(2)
257257
for c in components do
258258
expect(c).toBeInTheDocument()
259+
260+
test "Component inner let binding called props, should be correctly aliased" <| fun _ ->
261+
RTL.render(
262+
PropsAliasingTesting.InnerLetBindingPropsAliasing("test", 0)
263+
) |> ignore
264+
265+
let c = RTL.screen.getByTestId "props-aliasing"
266+
expect(c).toBeInTheDocument()

0 commit comments

Comments
 (0)