Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ci7lus opened this issue Mar 17, 2023 · 0 comments
Open

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

ci7lus opened this issue Mar 17, 2023 · 0 comments

Comments

@ci7lus
Copy link

ci7lus commented Mar 17, 2023

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);
 			}
 		})
 	},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant