Reactjs react限制渲染的数量
在react中,我展示产品,即 {renderPosts.map((项,索引)=>( 现在,在每个产品中,都有一个删除该产品的按钮,在我单击的一个按钮中,该按钮调用sweetAlert来删除特定的产品:Reactjs react限制渲染的数量,reactjs,sweetalert,Reactjs,Sweetalert,在react中,我展示产品,即 {renderPosts.map((项,索引)=>( 现在,在每个产品中,都有一个删除该产品的按钮,在我单击的一个按钮中,该按钮调用sweetAlert来删除特定的产品: <Button color="danger" simple justIcon onClick={warningWithConfirmMessage} > 一切都是这样运作的…但如果我想传递必须删除的产品ID <Button color="dange
<Button
color="danger"
simple
justIcon
onClick={warningWithConfirmMessage}
>
一切都是这样运作的…但如果我想传递必须删除的产品ID
<Button
color="danger"
simple
justIcon
onClick={warningWithConfirmMessage(item.postId)}
>
现在我有一个错误:
重新渲染过多。React限制渲染数量以防止无限循环
我怎么能把任何东西传给任何人
提前感谢!您正在传递的新
onClick
处理程序每次呈现时都会调用warningWithConfirmMessage
。要将函数作为处理程序函数传递而不是调用它,请使用:
onClick={() => warningWithConfirmMessage(item.postId)}
您正在传递的新
onClick
处理程序每次呈现时都会调用warningWithConfirmMessage
。要将函数作为处理程序函数传递而不是调用它,请使用:
onClick={() => warningWithConfirmMessage(item.postId)}
也许你的意思是,
onClick={()=>warningwithconfirmsessage(item.postId)}
-现在它每次渲染都调用warningwithconfirmsessage
。也许你的意思是onClick={()=>warningwithconfirmsessage(item.postId)}
-现在它每次渲染都调用warningwithconfirmsessage
。