RAN020 Reactive read at template build time
warning RAN020: count.Value is read once, when the template is built, so this text never updates.
Cause. Component.define builds a template once, when the definition is created, and setup and render's props reader run once per instance, untracked. A reactive read in a static text or attribute, in renderOf's or a component tag's static props, in setup's returned value, in render's or a component tag's props reader, or in an element expression's own if, match or for is a snapshot that never updates. A site inside an arms function or an items reader is RAN022's.
Fix. Yield or pass a reader (fun _ -> ...), or pass the signal and read it where it is used. The rule's fix wraps a static text, and an attribute whose reader overload returns the value's type.
Triggers
module Example
open Ranvier
open Ranvier.View
open Ranvier.View.Sugar
let count = createSignal 0
let counter = Component.template (fun _ () -> ()) (span () { string count.Value })
Fixed
module Example
open Ranvier
open Ranvier.View
open Ranvier.View.Sugar
let count = createSignal 0
let counter =
Component.template (fun _ () -> count) (span () { fun (c: Signal<int>) -> string c.Value })
Suppression. // fsharpanalyzer: ignore-line RAN020, with the reason on the line before. An intended snapshot, such as an initial value, takes the suppression.