Skip to content

Instantly share code, notes, and snippets.

@jonasdw
Created August 17, 2020 07:10
Show Gist options
  • Save jonasdw/5d4a121e82870954b9602813262a54fe to your computer and use it in GitHub Desktop.
Save jonasdw/5d4a121e82870954b9602813262a54fe to your computer and use it in GitHub Desktop.
type State = {
Domains: Domain list
Counter: int
}
// Imagine having a function somewhere dat increments our counter automatically (or manual whatever floats your boat)
let view .... =
div [] [
counter state.Counter
SomeComponent.render {| Domains = state.Domains |> List.filter (fun d -> d.Selected } |}
]
// Every time the counter gets incremented the state changes.
// View fn picks up that state change and filters the domains again (which havent been changed)
// That results in a new list and our function component gets rerendered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment