📌  相关文章
📜  error-too-many-re-renders-react-limits-the-number-of-renders-to-prevent - Javascript 代码示例

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

代码示例1
The problem can be found in your onClick prop:


                                            ^
Everything between the curly braces gets evaluated immediately. This causes the setOrderData_ function to be called in every render loop.

By wrapping the function with an arrow function, the evaluated code will result in a function that can be called whenever the user clicks on the button.^