anthonyshort / deku

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

Question: should `onUpdate` call when render returns the same thing? #387

Open rstacruz opened 8 years ago

rstacruz commented 8 years ago

should onUpdate be called when render returns the same thing (eg, when it was memoized)?

For instance:

var result = <div>hello</div>

module.exports = {
  render: () => result,
  onUpdate: () => { console.log('onupdate was called') }
}
anthonyshort commented 8 years ago

hrm, probably not. That does seem odd.

rstacruz commented 8 years ago

nah, i havent tested it, but i'm just wondering what the "spec" says. what if it's not memoized, but returns the same thing (that doesn't have sub-components)?

module.exports = {
  render: () => <div>hello!</div>,
  onUpdate: () => { console.log('onupdate was called') }
}

// should onUpdate be called twice if this was rendered twice?