From a55ad0e5b6936f83e490c89a9a3b6c163a98e14e Mon Sep 17 00:00:00 2001 From: "Dr. Sergey Pogodin" Date: Fri, 13 Oct 2023 19:20:41 +0200 Subject: [PATCH] [#15] v2.21.0-alpha.8: Android: Patches pickFile() for cancelled selection --- .../com/drpogodin/reactnativefs/ReactNativeFsModule.java | 2 +- example/src/App.tsx | 8 +++++--- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/drpogodin/reactnativefs/ReactNativeFsModule.java b/android/src/main/java/com/drpogodin/reactnativefs/ReactNativeFsModule.java index c6ab2bff..019fb15c 100644 --- a/android/src/main/java/com/drpogodin/reactnativefs/ReactNativeFsModule.java +++ b/android/src/main/java/com/drpogodin/reactnativefs/ReactNativeFsModule.java @@ -91,7 +91,7 @@ private ActivityResultLauncher getPickFileLauncher() { @Override public void onActivityResult(Uri uri) { WritableArray res = Arguments.createArray(); - res.pushString(uri.toString()); + if (uri != null) res.pushString(uri.toString()); pendingPickFilePromises.pop().resolve(res); } } diff --git a/example/src/App.tsx b/example/src/App.tsx index 05da0809..542f0a03 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -25,10 +25,12 @@ export default function App() {