[bug]: BackHandler.removeEventListener causes crash on React Native 0.72+ / Expo SDK 53
Description
Summary
The @walletconnect/modal-react-native package appears to call the deprecated BackHandler.removeEventListener() API, which was removed in React Native 0.72+. This results in a crash when navigating away from a screen that renders <WalletConnectModal /> on newer versions of React Native (including via Expo SDK 53, which uses RN 0.79).
WalletConnect Modal SDK version
1.1.0
Output of npx react-native info
info Fetching system and libraries information... System: OS: Windows 10 10.0.19045 CPU: "(8) x64 AMD Ryzen 7 4700U with Radeon Graphics " Memory: 3.65 GB / 15.23 GB Binaries: Node: version: 20.11.0 path: C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: version: 10.5.0 path: C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Not Found Visual Studio: - 17.4.33103.184 (Visual Studio Community 2022) Languages: Java: Not Found Ruby: Not Found npmPackages: "@react-native-community/cli": installed: 18.0.0 wanted: ^18.0.0 react: installed: 19.0.0 wanted: 19.0.0 react-native: installed: 0.79.2 wanted: 0.79.2 react-native-windows: Not Found npmGlobalPackages: "react-native": Not Found Android: hermesEnabled: Not found newArchEnabled: Not found iOS: hermesEnabled: Not found newArchEnabled: Not found
Expo Version (if applies)
53
Steps to reproduce
- Use
@walletconnect/[email protected]in a React Native app (e.g., with Expo SDK 53). - Render the
<WalletConnectModal />component inside a screen. - Navigate away from the screen.
Snack, code example, screenshot, or link to a repository
<WalletConnectModal
explorerRecommendedWalletIds={[
'',
]}
explorerExcludedWalletIds={'ALL'}
projectId={projectId!}
providerMetadata={metadata}
/>
hey @tommilleruk the issue might solve if you update react-native-modal to 14.0.0-rc.0
https://github.com/react-native-modal/react-native-modal/releases/tag/v14.0.0-rc.0
Also, have you thought of migrating to AppKit? We are about to release a new major version with Multichain support