Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

too many rerenders

// 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 --> <button onClick = { aFunction() } > I will cause a Rerender  </button> 
// YES --> <button onClick = { () => {aFunction()}  } > I will cause a Rerender  </button> 
 
PREVIOUS NEXT
Tagged: #rerenders
ADD COMMENT
Topic
Name
5+7 =