isBatchingUpdates
class List extends React.PureComponent {
constructor (props) {}
render () {}
onChange = () => {
// 开始,处于 batchUpdate
// isBatchingUpdates = true
// 其他操作
setTimeout(() => {
// 此时的 isBatchUpdates = false
this.setState({
number: this.state.number + 1
})
})
// 结束 isBatchingUpdates = false
}
}
// transaction 面向切片编程
transaction.initialize = function () { console.log('init') }
transaction.close = function () { console.log('close') }
function fn() { console.log('todo anything') }
transcation.perform(fn)