cerebral-legacy / cerebral-view-snabbdom

A JSX view package where Cerebral is first class citizen
MIT License
4 stars 1 forks source link

No docs/example on how to use snabbdom hooks. #4

Closed delaneyj closed 8 years ago

delaneyj commented 8 years ago

Coming from React I'm missing the ability to use things like didComponentMount. The snabbdom docs talk about insert/remove hooks. How do you access this in cerebral-snabbdom components?

christianalfoni commented 8 years ago

Hi there, I have not tried them you, but they work like props of an element, it really has nothing to do with the component. So:

Component(({signals}) => (

  <div hook={{insert(vnode) { signals.appInserted(); }}>hey</div>

));
christianalfoni commented 8 years ago

I think it is more powerful as you can do it on any node actually.

delaneyj commented 8 years ago

Thanks for the clarification, I thought it would default to the props or attrs dictionary.