Skip to content

Support the Backhandler React Native API #4606

@DrewHiggins

Description

@DrewHiggins

Proposal: Support the Backhandler React Native API on Windows

Summary

React Native has a Backhandler API that detects when the user presses the hardware back button on Android and tvOS devices and calls listeners that subscribe to it. Having support for this in Windows with the various input methods for back navigation (mouse button, Xbox controller B button, etc.) would be useful.

Currently, this API is scaffolded out with empty functions and TODOs, but no open issue is tracking it (the last issue I could find was from the last version of RNW based on .NET).

Motivation

Users expect native Windows app to support mouse back button, and the JS/web APIs for detecting it aren't great, since the browser would normally handle back button behavior. The UWP documentation also recommends that apps implement support for common back inputs.

Basic example

import { BackHandler } from 'react-native';
// ...
BackHandler.addEventListener("hardwareBackPress", this.props.onBackRequested);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions