ViewRefs are not updated in UpdateIncremental
Dolfik1 opened this issue · comments
Nikolay M commented
Hi. I am facing problem. It seems that Fabulous does not set ViewRef
value when ViewRef
is changed. There is simple repro:
type Model = { LabelRef: ViewRef<Label> }
type Message =
| ResetViewRef
| UpdateText
let update msg model =
match msg with
| ResetViewRef ->
{ model with LabelRef = ViewRef<_>() }, Cmd.none
| UpdateText ->
model.LabelRef.TryValue |> Option.iter (fun x -> x.Text <- "Hello, world from ref!")
model, Cmd.none
let view model dispatch =
View.StackLayout(
orientation = StackOrientation.Vertical,
children = [
View.Label(
text = "Hello, world!",
ref = model.LabelRef
)
View.Button(
text = "Update ref",
command = (fun _ -> dispatch ResetViewRef)
)
View.Button(
text = "Update text via ref",
command = (fun _ -> dispatch UpdateText)
)
])
Repro steps
- Press "Update ref" button.
- Press "Update text via ref" button.
Expected behavior
Text changed to "Hello, world from ref!"
Actual behavior
Text does not change.