渲染10000个阶段,时间切片计算出错
ctime-zliang opened this issue · comments
c.zliang commented
function View() {
const [key, setKey] = useState([])
const modifyList = () => {
const array = []
for (let i = 0; i < 10000; i++) {
array.push(Math.random())
}
setKey(array)
console.log(key, array)
}
return (
<div className="row-view">
<div onClick={() => { modifyList() }}>Modify List {key.length}</div>
<ul>
{key.map((item, index) => {
return <li>{item}</li>
})}
</ul>
</div>
)
}
render(<View />, document.getElementById('app'))
上述代码,点击后,li 节点没有被添加到 DOM