Discussed in #696
Originally posted by ruggi99 March 31, 2022
Hi all,
I tried to use useToggle on a <button> to toggle a menu but it doesn't work because when used directly in a <button> the first argument is always the event fired.
function MyComponent() {
const [state, toggleState] = useToggle(false);
return <button onClick={toggleState}>Toggle me!<button>
}
I'm wondering if we can ignore the first argument if it is an event (or a click event in this case).
The workaround for now is using onClick={() => toggleState()} but is not stable across renders.
Thanks
Discussed in #696
Originally posted by ruggi99 March 31, 2022
Hi all,
I tried to use
useToggleon a<button>to toggle a menu but it doesn't work because when used directly in a<button>the first argument is always the event fired.I'm wondering if we can ignore the first argument if it is an event (or a click event in this case).
The workaround for now is using
onClick={() => toggleState()}but is not stable across renders.Thanks