Why is my function being called twice in React?

前端 未结 4 1619
被撕碎了的回忆
被撕碎了的回忆 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:37

    Prevent calling twice by using e.preventDefault().

    changeShipping(e){
       e.preventDefault();
       console.log('clicked');
    }
    

提交回复
热议问题