We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 61e653d commit 61c6bb0Copy full SHA for 61c6bb0
packages/native/src/useLinking.native.tsx
@@ -30,9 +30,18 @@ export default function useLinking(
30
subscribe = (listener) => {
31
const callback = ({ url }: { url: string }) => listener(url);
32
33
- Linking.addEventListener('url', callback);
34
-
35
- return () => Linking.removeEventListener('url', callback);
+ const subscription = Linking.addEventListener('url', callback) as
+ | { remove(): void }
+ | undefined;
36
+
37
+ return () => {
38
+ // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7
39
+ if (subscription?.remove) {
40
+ subscription.remove();
41
+ } else {
42
+ Linking.removeEventListener('url', callback);
43
+ }
44
+ };
45
},
46
getStateFromPath = getStateFromPathDefault,
47
}: LinkingOptions
0 commit comments