Skip to content
This repository has been archived by the owner on Sep 13, 2020. It is now read-only.

Allow external toggle function #368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Allow external toggle function #368

wants to merge 1 commit into from

Conversation

traviisd
Copy link

I'm not sure if anyone else experiences this issue, but when the SideMenu is opened and closed via an external trigger, you have to tap the external button again in order for the toggle to work.

I thought this issue was related to facebook/react-native#12784, but everything I tried still resulted in the "toggle" button needing to be pressed twice after close. After debugging, I narrowed it down to this package. When I remove this package, buttons work just fine.

The behavior seems to only happen after the SideMenu is open. The menu closes, but any onPress function does not fire after, until it's pressed again. The internal state of the component updates the isOpen prop on local state.

This proposed change allows an externalToggle (function) be passed in, which fires when the "overlay" component is pressed.

Feedback is greatly appreciated as I don't know if this is a good workaround and/or update to the package. Additionally I'm not well versed with TypeScript.

@nickineering
Copy link
Contributor

I've seen weird stuff where it triggers the event twice, but was able to get it to work without this using just the isOpen and onChange props. onChange just updates the state which is used as isOpen. Then I can just change the state to toggle the menu, but normal menu operation works just fine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants