I am trying to write a simple application in Fable, but I have problems setting up elements. I am not able to add new elements without ruining the existing ones.
let view model dispatch =
div [ Class "main-container" ]
[ input [ Class "input"
Value model.Value
OnChange (fun ev -> ev.target?value |> string |> ChangeValue |> dispatch) ]
span [ ]
[ str "Hello, "
str model.Value
str "!" ] ]
This is the example from fable.io webste. I am trying to add, for example, another input, text, button or any other element, but how can I? I cannot find any rules that need to be followed. What am I missing on?
UPDATE:
let view model dispatch =
let digit n = digitBtn n dispatch
div
[ calcStyle ]
[
br []
table []
[ digit 1 ] ]
yields the error
Type mismatch. Expecting a 'Model -> Dispatch -> 'a' but given a 'Model -> (string -> unit) -> Fable.Import.React.ReactElement' The type 'Msg' does not match the type string
calcStyleanddigitBtnfunctions, but if I just remove the style (leave an empty list) and havelet digit n = button [ Type "button" ] [ str (n.ToString()) ], it does compile... Can you post the rest of the file? (Program.mkProgram ...) - psfinakidigitBtnis, but it seems to expect a different dispatch function than what you're getting inviewhere. In that case you either need to change howdispatchis used indigitBtnor pass it a dispatch function that conforms to what it expects. A common pattern is to wrap the dispatched value in aMsgvariant by doingMyMsgVariant >> dispatch- glennsl