Why is my function being called twice in React?

前端 未结 4 1625
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 17:59

I have an idea that this may be because I am doing some styling things to change my radio button, but I am not sure. I am setting an onClick event that is calling my functio

4条回答
  •  孤街浪徒
    2020-12-15 18:32

    e.stopPropagation() is also worth exploring. I was handling an onMouseDown event, and preventDefault was not preventing multiple calls.

    https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation

提交回复
热议问题