Appearance
react批量处理unstable_batchedUpdates
unstable_batchedUpdates
可用于手动批量更新state
,可以指定多个setState
合并为一个更新请求
typescript
function handleInputChange(e) {
const keyword = e.target.value
unstable_batchedUpdates(() => {
setQuery((prevState) => ({ ...prevState, keyword }))
setPagination((prevState) => ({ ...prevState, page: 1 }))
})
}