fix: handle updater’s return value

This commit is contained in:
EnixCoda 2018-09-11 21:42:25 +08:00
parent 2ebd8c8fa7
commit 9be44e4e73

View file

@ -22,11 +22,9 @@ function link(instance, sources) {
// luckily I don't need them :)
let [updater, callback] = args
if (typeof updater === 'function') {
callback = updater
callback(instance.state, instance.props)
} else {
instance.setState(updater, callback)
updater = updater(instance.state, instance.props)
}
instance.setState(updater, callback)
}
}