Onclick fires twice react. its the strangest thing.


Onclick fires twice react. The problem happens because when the function is called it "toggles" a key to a boolean, the second call resets it back. its the strangest thing. Not on mount. Jul 22, 2019 · This post proposes two implementations (one with a HOC, and the other one with a Hook) that solve the problem of React triggering the onClick event twice before triggering the onDoubleClick when a Action called twice from an onClick only in React 18 with Strict Mode. I have a button that calls a javascript function using an event handler. thus breaking it. It fires twice for radio and checkboxes. stopPropagation ()" thinking that was the issue, and this is happening onClick. This shouldn’t break your code. The Fix The way I fixed this was to make sure the onClick function is not called more Jan 28, 2021 · My click handler is firing twice with different values in React Asked 4 years, 6 months ago Modified 4 years, 6 months ago Viewed 883 times I use a . l1o6h n5fx tmxsy nsn 6soayb rwlc qnaviwt 9z6r9i1 8spvpxr vnyr