Skip to content

RAN010 Owned node created in a pure derivation

error RAN010: createEffect creates an owned node inside createMemo's body, which fails every read of the memo.

Cause. A memo, effect, async value, boundary, root, projection, lookup, selector or onCleanup created in a pure derivation fails the derivation's run with InvalidOperationException: the body of createMemo or Memo (graph, compute), the compute of createAsync and createEffectOn, a projection's map or row reader, a lookup's f and affected, an editable's seed, and a projection aggregate's functions. A creator under untrack or inside try ... with fails the same way. A creator inside a nested lambda, other than untrack and batch, is not reported, even one that runs immediately, such as List.map's.

Fix. Use the owning form (createMemoWith, createAsyncWith), or create the node outside. The rule's fix renames the memo and async creators.

Triggers

module Example

open Ranvier

let label (topic: Signal<string>) =
    createMemo (fun _ ->
        onCleanup ignore
        topic.Value)

Fixed

module Example

open Ranvier

let label (topic: Signal<string>) =
    createMemoWith (fun _ ->
        onCleanup ignore
        topic.Value)

Suppression. // fsharpanalyzer: ignore-line RAN010, with the reason on the line before.

Edit this page