cyntler / hamburger-react

Animated hamburger menu icons for React.js weighs only 1.5 KB.
https://hamburger-react.netlify.app
MIT License
963 stars 36 forks source link

Add event to toggle handlers #40

Closed Nicktho closed 3 years ago

Nicktho commented 3 years ago

Hi there, great library!

I have a use case for handling the click event of the hamburger component. I've gone ahead and suggested a way to incorporate it into the api, as a second argument to toggle and onToggled, let me know what you think!

luukdv commented 3 years ago

Thanks for the PR! I was actually planning on removing onToggle in 3.0, in favor of:

useEffect(() => {}, [toggled])

Besided that, a few questions about this PR:

const [toggled, toggle] = useState(false)

<Hamburger toggled={toggled} toggle={toggle} />
luukdv commented 3 years ago

Closing due to inactivity.

JaapWeijland commented 2 years ago

Just wanted to drop by saying that I need the click event to stop propagation. I know asking for something without contributing is not really the nicest thing to do, but this may help you prioritise new features.