Skip to content

Commit 8d423e4

Browse files
authored
Merge pull request #1076 from fabulous-dev/fix-scalar-attributes-data-key-lookup
Fix ScalarAttributes data key lookup
2 parents 062f9e8 + 6637de5 commit 8d423e4

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
_No unreleased changes_
1111

12+
## [3.0.0-pre4] - 2024-04-16
13+
14+
### Changed
15+
- Find the component data key in ScalarAttributes by @edgarfgp (https://github.com/fabulous-dev/Fabulous/pull/1076)
16+
1217
## [3.0.0-pre3] - 2024-04-12
1318

1419
### Changed
@@ -125,7 +130,8 @@ _No unreleased changes_
125130
### Changed
126131
- Fabulous.XamarinForms & Fabulous.MauiControls have been moved been out of the Fabulous repository. Find them in their own repositories: [https://github.com/fabulous-dev/Fabulous.XamarinForms](https://github.com/fabulous-dev/Fabulous.XamarinForms) / [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls)
127132

128-
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre3...HEAD
133+
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre4...HEAD
134+
[3.0.0-pre4]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre4
129135
[3.0.0-pre3]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre3
130136
[3.0.0-pre2]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre2
131137
[3.0.0-pre1]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre1

src/Fabulous/MvuComponent.fs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,25 @@ module MvuComponent =
9999
let canReuseMvuComponent (prev: Widget) (curr: Widget) =
100100
let prevData =
101101
match prev.ScalarAttributes with
102-
| ValueSome attrs when attrs.Length > 0 -> attrs[0].Value :?> MvuComponentData
102+
| ValueSome attrs ->
103+
let scalarAttrsOpt =
104+
attrs |> Array.tryFind(fun scalarAttr -> scalarAttr.Key = Data.Key)
105+
106+
match scalarAttrsOpt with
107+
| None -> failwithf "Component widget must have a body"
108+
| Some value -> value.Value :?> MvuComponentData
109+
103110
| _ -> failwith "Component widget must have a body"
104111

105112
let currData =
106113
match curr.ScalarAttributes with
107-
| ValueSome attrs when attrs.Length > 0 -> attrs[0].Value :?> MvuComponentData
114+
| ValueSome attrs ->
115+
let scalarAttrsOpt =
116+
attrs |> Array.tryFind(fun scalarAttr -> scalarAttr.Key = Data.Key)
117+
118+
match scalarAttrsOpt with
119+
| None -> failwithf "Component widget must have a body"
120+
| Some value -> value.Value :?> MvuComponentData
108121
| _ -> failwith "Component widget must have a body"
109122

110123
// NOTE: Somehow using = here crashes the app and prevents debugging...

0 commit comments

Comments
 (0)