I am trying to understand the very first project that is generated when you create a elmish/fable project like so: dotnet new fable-react-elmish
:
let view (model: Model) dispatch =
let resultView =
match model.downloaded with
| Ok r ->
h3 [ Style [CSSProp.Color "blue"] ] [ str r ]
| Error er ->
h3 [ Style [CSSProp.Color "red"] ] [ str er ]
div [] [
h1 [] [ str "React Elmish demo" ]
button [ OnClick (fun _ -> dispatch OnDownloadClicked) ] [ str "Download" ]
button [ OnClick (fun _ -> dispatch ResetClicked) ] [ str "Reset" ]
div [] [ h2 [] [ str "Download result:" ]; resultView ]
]
I understand that every time one of the functions OnDownloadClicked
or ResetClick
is called, a <h3>
HTML control is displayed as the last control of the HTML page, overwriting the old one. (Probably the whole page is reloaded, but I'm not sure)
But how would I modify the above example in order to have a new <h3>
element added to the view every time the OnDownloadClicked
function gets called? In other words: I'd like to have all formerly displayed <h3>
elements being kept on the view. Any hints (also those pointing to examples) are welcome.