You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do these listeners really need to be hooks? Maybe just set the on* stuff.
What exactly does this mean; why are there effectively two "click"s in your vnodes? I notice the String is passed to addEventListener inside the HookFn, but the record name doesn't appear to affect anything.
vnode "div" { click: hook "click" handler } [ ]
The text was updated successfully, but these errors were encountered:
With virtual-dom, you can make your own custom vnode properties and name them whatever you want as long as their value is a "hook". The hook defines what happens when such a custom property is added or removed. So you're right, the property name "click" doesn't affect anything. I could have called it "banzai" or "orange" or whatever. But I need to call it something so that virtual-dom can compare it between renders to the previous value and do an update if needed. I happened to call it click because it is a hook that sets up a click handler.
The comment about needing to be hooks is implying that this is a dumb way to do it. You don't need hooks to set up click handlers because you can just use the "onclick" property as long as the value you provide to onclick has the correct form. I was experimenting with vdom and trying things out, which is why the hook method is still in there with a comment suggesting a better way to do it.
You might also want to check out puzzler2, which uses the onclick, etc, directly. That implementation has its own set of problems, but I think is overall cleaner in terms of the view.
What exactly does this mean; why are there effectively two "click"s in your
vnode
s? I notice the String is passed toaddEventListener
inside theHookFn
, but the record name doesn't appear to affect anything.The text was updated successfully, but these errors were encountered: