Skip to content

How to use the elmish hooks from a component? (0.6.0-preview6) #256

Closed Answered by JordanMarr
marklam asked this question in Q&A
Discussion options

You must be logged in to vote

I've found something interesting.
For some reason, conditionally creating the TextBlock causes the issue.

It works if the TextBlock is always created, but only the value changes:

module TaskView =
    let update msg model =
        printfn $"Msg.update {msg}"
        match msg with
        | UpdateValue ->
            let v = (model.Value |> Option.defaultValue 0) + 1
            { model with Value = Some v }, Cmd.none

    let create key (_model : IWritable<Model>) =
        Component.create (key,
            fun ctx ->
                printfn "TaskView render"
                let model = ctx.usePassed(_model, renderOnChange = true)
                let model, dispatch = ctx.useElmish (model

Replies: 3 comments 12 replies

Comment options

You must be logged in to vote
1 reply
@marklam
Comment options

Comment options

You must be logged in to vote
5 replies
@marklam
Comment options

@JordanMarr
Comment options

@JordanMarr
Comment options

@marklam
Comment options

@JordanMarr
Comment options

Answer selected by marklam
Comment options

You must be logged in to vote
6 replies
@JordanMarr
Comment options

@marklam
Comment options

@JordanMarr
Comment options

@marklam
Comment options

@JordanMarr
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants