question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onBackdropPress not functioning as expected on Android

See original GitHub issue

So I’ve been trying to use the newly implemented onBackdropPress to close a modal when the backdrop is pressed. As it wasn’t working originally, I decided to replace the functionality with a console log to see when onBackdropPress is being called.

From what I can see, the only times it’s firing off are when I open the modal originally, and when I close the modal using onBackButtonPress. Nothing seems to be triggered when I tap the modal itself.

I’ve attempted to move the modal to different levels in component structure (I have a number of child components and ideally wanted to call it from the very last child), but it seems to function the same regardless of where it is.

My usage of the modal looks like this:

<Modal
    isVisible = {this.props.visible}
    backdropColor = 'red'
    onBackdropPress = {console.log("Pressed")}
    onBackButtonPress = {this.props.closeModal}>
    <View style = {styles.modalView}>
        ...
    </View>
</Modal>

Dependencies in use: react-native-modal 3.1.0. react 16.0.0-alpha.12 react-native 0.47.2

I’m running on a Samsung Galaxy S5.

Here’s a link to a basic expo app which shows the issue: https://github.com/vanhoutk/modaltest

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mmazzarolocommented, Aug 31, 2017

Thanks, the following won’t work though:

onBackdropPress = {console.log("Pressed")}

Try replacing it with:

onBackdropPress = {() => console.log("Pressed")}

Let me know if the issue still persists.

Also, does the provided eximple work for you? https://github.com/react-native-community/react-native-modal/tree/master/example/src

0reactions
lukewlmscommented, Oct 17, 2017

@vanhoutk that call would happen anytime the component is mounted - console.log is called, and the resulting value (null) is set to onBackdropPress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[React-Native-Modal]: onBackButtonPress prop returns nothing
I use this library too react-native-modal and onBackButtonPress is working fine. I face another issue, in my case onBackdropPress is not ...
Read more >
react-native-modal - npm
Start using react-native-modal in your project by running `npm i react-native-modal`. ... The component is not working as expected.
Read more >
keyboardavoidingview modal | The search engine you control.
So move the KeyboardAvoidingView inside of the Modal to get the expected behaviour. ... KeyboardAvoidingView not working in a Modal (React-Native).
Read more >
“react native modal on backdrop press not working” Code ...
Answers related to “react native modal on backdrop press not working”. $('#mymodal').modal('show') not working · react native modal not full screen ...
Read more >
React Native Modal Drawer - Vela Cloud
If you have not installed React Native CLI globally, install it using the following command ... Подсветка текущего меню Active Drawer в React...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found