Skip to content

BackHandler and remote debug #15497

@sm2017

Description

@sm2017

Is this a bug report?

(Yes)

Have you read the Contributing Guidelines?

(Yes)

Environment

  1. react-native -v:
react-native-cli: 2.0.1
react-native: 0.47.1
  1. node -v:
v8.1.3
  1. npm -v:
5.0.3
  1. yarn --version:
0.27.5

Then, specify:

  • Target Platform: Android
  • Development Operating System: Windows10
  • Build tools: react-native run-android

Steps to Reproduce

(Write your steps here:)

class App extends Component {
  componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', this.onBackPress);
  }
  componentWillUnmount() {
    BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
  }
  onBackPress = () => {
    return true;
  };
  render() {
    return (
      <Text>Press back buton</Text>
    );
  }
}

If you run the code in development environment , it don't works and when you press back button , app will be closed , but in development environment if you turn on remote debug , the code works well and app not closed

Expected Behavior

(Prevent closing app on back button pressed)

Actual Behavior

(On development environment when remote debug is off it don't woks but when remote debug is on it works)

Reproducible Demo

(N/A)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugHelp Wanted :octocat:Issues ideal for external contributors.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions