I have defined a Mutable inside a Javascript block.
let count = Mutable(0)
....
some htmls and then another JS block
if (some condition)
count++
The above results in “Assignment to an external variable …”
Even ++count.value results in the following error -
Cannot create property ‘value’ on number ‘0’
Please the example in the docs:
https://observablehq.com/framework/reactivity#mutables
Other code blocks can only see the reactive value of the mutable when they reference it directly. If you want to assign the value of the mutable from another block, you need to define a mutator (e.g. incrementCount
) in the same block, and then call it from the other block.