小编Jan*_*zub的帖子

Fable React 有状态组件上的 Elmish 调度

我需要使用带有 elmish 调度的 Fable-React 有状态组件。我不知道如何创建它。

我正在使用这个项目模板:https : //github.com/fable-elmish/templates

这是模型:

module Home.Types

    [<Pojo>]
    type Model = {
        isLoading:                  bool
    }
Run Code Online (Sandbox Code Playgroud)

这是组件:

type Documentation(props) as this =
    inherit Component<Documentation.Types.Model,obj>(props)
    do
        ()

    override this.componentWillMount () =
        printfn "componentWillMount"
        **RequestProcessDocumentation |> dispatch <-- this is what I need**

    override this.render() =
        printfn "render"
        let (?) = Fable.Core.JsInterop.(?)

        div []
            [
                p [] [str(this.props.isLoading.ToString())]
                button [ OnClick (fun _ -> RequestProcessDocumentation |> dispatch ) ] [str("Click me")]
            ]
Run Code Online (Sandbox Code Playgroud)

如何使用 ofType 函数创建它,然后我可以像这样使用它:

  let pageHtml = …
Run Code Online (Sandbox Code Playgroud)

f# fable-f# elmish

5
推荐指数
1
解决办法
562
查看次数

标签 统计

elmish ×1

f# ×1

fable-f# ×1