anthonyshort / deku

Render interfaces using pure functions and virtual DOM
https://github.com/anthonyshort/deku/tree/master/docs
3.41k stars 130 forks source link

onCreate and DOM effects #389

Closed 11111000000 closed 8 years ago

11111000000 commented 8 years ago

rc-15 I try to inject some generated content to <div id={ path }></div> in SomeComponent with it's onCreate hook ( middleware is better, yes), but I found getElementById(path) == null (after next rendering (or HMR), things are on its places). Is this ok? I think, in 1.0 on first afterRender DOM are already generated.

anthonyshort commented 8 years ago

Yeah that's expected behaviour. You'll need to do something like setTimeout(fn, 0) or requestAnimationFrame(fn) to manipulate the DOM element.

11111000000 commented 8 years ago

Ah, yes, thanks