phenomejs / phenome

The ultimate cross-framework component compiler
http://phenomejs.org
MIT License
71 stars 8 forks source link

Implement watchers for React #3

Closed nolimits4web closed 6 years ago

nolimits4web commented 6 years ago

Should be in componentWillUpdate or componentDidUpdate. @bencompton do you have an idea what is the better hook to place it?

Usage, same as in Vue component with props/state prefix:


watch: {
  'props.foo': function (newValue, oldValue) {
     ...
  },
  'state.bar': function (newValue, oldValue) {
    .. 
  }
}
bencompton commented 6 years ago

@nolimits4web, in Framework7 React, I did it in componentWillReceiveProps and that seemed to make F7 React work the same as F7 Vue.

nolimits4web commented 6 years ago

Read this https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html this morning. Looks like “will” hooks are going to be deprecated soon

bencompton commented 6 years ago

@nolimits4web - nice, hadn't read that. I suppose we had better stop using them then. It's just a matter of ensuring that it matches up with Vue's behavior, since the timing can be important in a lot of cases in F7 especially.

nolimits4web commented 6 years ago

Fixed with bced76e640dcc81fece9c1b60a76ac942b3df6bb