fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming

Home Page:https://fabulous.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ViewRefs are not updated in UpdateIncremental

Dolfik1 opened this issue · comments

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

  1. Press "Update ref" button.
  2. Press "Update text via ref" button.

Expected behavior

Text changed to "Hello, world from ref!"

Actual behavior

Text does not change.