Comments (6)
Maybe I'm missing something but isn't onModalHide
enough to achieve your desired effect?
You just navigate to the previous screen when onModalHide
is triggered. 🤔
Thank you for noticing the hideOnBack
missing documentation, I'm adding it right now :)
from react-native-modal.
Thanks for the quick reply!
The thing is that I don't think I can tell that onModalHide
was called as a result of the Back button being pressed. In my particular case, there are other triggers that can cause the modal to go away, and I want to treat the Back button differently.
from react-native-modal.
I think I got it now :)
Did you already try handling the back button press by catching it in the modal's parent component (through react-native's backandroid)?
I'm not a master of the Android back button functionality but it seems that toying a bit with it should solve your issue.
If it doesn't work I guess another solution would be making this component close when changing it's isVisible
prop, but it would require a bit more code on my side... so let me know if the first solution works first! :)
from react-native-modal.
I have a listener for back button at the very "top level" of my app, and when I set hideOnBack
to false
my listener isn't getting called. I guess that react-native's Modal swallows the notification somehow. I actually didn't try installing a handler in the modal's parent component. Will give it a try.
Not sure I follow what you meant by closing when changing isVisible
, but would it be possible for react-native-modal to expose a callback from closeOnBack
(or maybe provide an argument to the onModalHide
callback that indicates wasClosedByBack
)? I don't think this should require too much code. I can try it tomorrow and send it as a pull request if it makes sense to you.
from react-native-modal.
Honestly, I wanted to preserve closeOnBack
/onRequestClose
to the current status for another nifty future I planned (hiding modal on backdrop press) but in the end add a callback shouldn't interfere too much at all so... sure, you can do it, a PR is very much welcome :)
Thanks!
from react-native-modal.
Released on v2.2.0, closing!
from react-native-modal.
Related Issues (20)
- react-native-modal does not work when react-native-inappbrowser is open (iOS only)_ HOT 4
- Is there a way to make both the modal and background screen to be interactable. HOT 1
- [Android]: OnPress not working when modal is open after updating react native version HOT 14
- Bug: Element Modal doesn't have required attribute ... HOT 2
- Close/Dismiss all modals which are open at once. HOT 1
- TypeError: _reactNative.InteractionManager.clearInteractionHandle is not a function HOT 1
- Android: Modal Pops up even if you're on a different screen
- Asking for Help: why the half-bottom-modal not reach the bottom in Android HOT 1
- Samsung One Ui is blocking modal when requested for android permission at same time.
- The application crashes when the component is unmounted, caused by the fact that DeviceEventEmitter does not recognize that it has the removeListener method. HOT 3
- Jest test cases not working with react-native-modal HOT 1
- Press events no longer propagating to children after Expo 49 upgrade HOT 1
- BackHandler is not supported on web and should not be used HOT 2
- Loading the modal on first render of screen means backdrop doesn't show
- react native modal keyboad open i want once backbutton pressed to close the keyboard and the modal at the same time
- react native modal keyboad open i want once backbutton pressed to close the keyboard and the modal at the same time onBackdropPress working
- Brief comments on the purpose of your changes: HOT 1
- Modal Animation Issue: Brief Left-to-Bottom Transition on Android/iOS HOT 2
- App freezes on clicking of outside of the content (backdrop) after orientation changes in ipad
- modal still showing when set to false when from prev screen , when nav back showing modal HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-modal.