Skip to content

Commit 95d989b

Browse files
committed
Fix ScalarAttributes data key lookup
1 parent 062f9e8 commit 95d989b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

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)