Closed mietennet closed 6 years ago
gotcha, hyperapp recycles the section-element...
if i add a key to the element then it works as expected:
<section key={prop.id} oncreate={element => console.log('created', prop.id)}>
is this intended?
@mietennet Yes, definitely. 👍
@mietennet Yup! This is exactly (one of) the purpose of keys: controlling when elements are destroyed/created vs reused.
ok, thanks...
is it also intended, that i have to use oncreate inside my component-function but not like that:
<Panel id={i} current={i === state.currentPanel} oncreate={element => console.log('created', i)}>
This is Panel {v}
</Panel>
Yeah kind of intended: oncreate is about elements, and only means something when attached to a vnode. Your Panel is just a function that returns the section vnode.
It's one of those things that's less confusing if you're not using JSX
ok, thanks again!
great work, guys
if i'm doing that:
everything works as expected and i get a couple of "created x" at my console log
but if i'm changing to this, to render only the active panel:
now i get one console log for the first element, then if i change state.currentPanel the app works as expected but without triggering the oncreate... so no further console line!
any ideas?