-
Here's the fiddle of my issue: https://jsfiddle.net/ujr51hze/ What I've tried:
Even in its example code, one handler is wrapped in |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey! From my current understanding, Under the hood, this means assigning to the function you give it a variable // from van.js
else if (protoOfV === funcProto && (!k.startsWith("on") || v._isBindingFunc))
bind(() => (setter(v()), dom)) // internal function to bind the DOM to the state setter So in your fiddle, modifying div(
{ class: "tabs-active-content-area" },
tabItems[activeIndex.val].content
// this will only use the current snapshot of `activeIndex.val`,
// without binding this div to the state
) to be div(
{ class: "tabs-active-content-area" },
van._(() => tabItems[activeIndex.val].content)
// the function inside returns the same value, but allows vanjs
// to bind the div to the state setter and update when it is triggered
) will bind (correct me if this intuition is wrong!) |
Beta Was this translation helpful? Give feedback.
-
Thank you @csm-kb . This fixes it. But something I haven't quite understood yet about the |
Beta Was this translation helpful? Give feedback.
So in the same vein as state-derived children, you could actually just pass
and function the same way, too.
van._()
isn't actually needed here!