📌  相关文章
📜  太多的重新渲染 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:53.133000             🧑  作者: Mango

代码示例1
// A number of different things can trigger this. 

// setting up useEffect in this way and changing state inside its callback can cause an infinite loop of rerenders. 
useEffect( () => {
 setState() // (state is being updated here using stateSetter()
})

// onClick expects a callback, notice the subtle difference bw passing a called function and passing a callback that called a function. 
// this can cause unintended renders.
 // NO -->  
// YES -->