Skip to content

Linking.removeEventListener was removed in react-native 0.71 #12

@ci7lus

Description

@ci7lus

I’m using this library in react-native iOS. I noticed it was broken in react-native 0.71.
removeEventListener was existed in https://reactnative.dev/docs/0.70/linking, but was removed in https://reactnative.dev/docs/linking.

image

hotfix patch is here

diff --git a/index.js b/index.js
--- a/index.js
+++ b/index.js
@@ -93,8 +93,12 @@ const RNSquarePos = {
 					}
 				})
 
+				let subscription = null;
+
 				function handleIOSResponse(event) {
-					Linking.removeEventListener('url', handleIOSResponse);
+					subscription.remove()
 					const url = event.url
 
 					if (url.match(callbackUrl)) {
@@ -120,7 +124,7 @@ const RNSquarePos = {
 					}
 				}
 
-				Linking.addEventListener('url', handleIOSResponse);
+				subscription = Linking.addEventListener("url", handleIOSResponse);
 			}
 		})
 	},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions