wavesoft / dot-dom

.dom is a tiny (512 byte) template engine that uses virtual DOM and some of react principles
Apache License 2.0
806 stars 53 forks source link

Best way to detect node had loaded? #18

Closed simonwjackson closed 7 years ago

simonwjackson commented 7 years ago

Any way to react once the vnode has been rendered to the screen?

This doesn't seem to work:

function utterance(props, state, setState) {
  let inner = 'hey'
  let obj = {
    onload () {
      this.setAttribute("data-id", props.id)
    }
  }
  return H('div', obj, inner);
}

R(H(utterance), document.body)
wavesoft commented 7 years ago

You might have to wait for the lifecycle methods. I am currently thinking for the best approach to it, so be aware that the API might change. Nonetheless, you can try to use the build from here https://github.com/wavesoft/dot-dom/blob/ba038fbda06ad17d3deb983605fd406f3060851b/dotdom.min.js

An you can see an example of the new API in the PR here https://github.com/wavesoft/dot-dom/pull/12

simonwjackson commented 7 years ago

Wow, that's fantastic! Thanks again!

wavesoft commented 7 years ago

This will be resolved with #12 please comment there if there are any other issues 👍