I have a strange issue with karax. When the text in the buttons are the same (so both are "FOO") then i can not toggle back and forth. When the text in one of them is changed, lets say
= "BAA"
than toggle works.
Is this a bug?
include karax / prelude
import jsffi, future
type Comp = object
menu: int
proc createDom(comp: var Comp): VNode =
result = buildHtml(tdiv):
text repr comp
case comp.menu
of 0:
text "Hello World!"
button(onclick = () => (comp.menu = 1)):
text "FOO"
of 1:
text "Other World!"
button(onclick= () => (comp.menu = 0)):
text "FOO"
else: discard
var comp = Comp()
comp.menu = 0
setRenderer(proc (): VNode = createDom(comp), root="ROOOT")
I can force redraw with:
# ...
of 0:
text "Hello World!"
button(onclick = () => (comp.menu = 1; avoidDomDiffing())):
text "FOO"
of 1:
text "Other World!"
button(onclick = () => (comp.menu = 0; avoidDomDiffing())):
text "FOO"
#...