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

@deprecated Use the remove() method on the event subscription returned by addEventListener(). #92

Closed
URvesh109 opened this issue May 21, 2022 · 5 comments

Comments

@URvesh109
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch rn-swipe-button@1.3.7 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rn-swipe-button/src/components/SwipeButton/index.js b/node_modules/rn-swipe-button/src/components/SwipeButton/index.js
index e77cacd..d9f7df5 100644
--- a/node_modules/rn-swipe-button/src/components/SwipeButton/index.js
+++ b/node_modules/rn-swipe-button/src/components/SwipeButton/index.js
@@ -48,7 +48,7 @@ const SwipeButton = props => {
       setScreenReaderEnabled(isEnabled);
     };
     setIsUnmounting(false);
-    AccessibilityInfo.addEventListener('change', handleScreenReaderToggled);
+    const subscription = AccessibilityInfo.addEventListener('change', handleScreenReaderToggled);
 
     AccessibilityInfo.isScreenReaderEnabled().then(isEnabled => {
       if (isUnmounting) {
@@ -59,10 +59,11 @@ const SwipeButton = props => {
 
     return () => {
       setIsUnmounting(true);
-      AccessibilityInfo.removeEventListener(
-        'change',
-        handleScreenReaderToggled,
-      );
+      subscription.remove();
+      // AccessibilityInfo.removeEventListener(
+      //   'change',
+      //   handleScreenReaderToggled,
+      // );
     };
   }, [isUnmounting, screenReaderEnabled]);
 

This issue body was partially generated by patch-package.

@JakeOrel
Copy link

JakeOrel commented Jun 8, 2022

can we get this change in a pr ?

@rasmusviben
Copy link

Any news for this change? :)

@ElpayetSupervan
Copy link
Contributor

ElpayetSupervan commented Aug 30, 2022

@JakeOrel @rasmusviben @UdaySravanK I tried to make a PR but was unable to launch the example project locally to test it. Right now it only reflects changes proposed by @URvesh109, without testing on my side.

I have this error when trying to launch the example project :
Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @3cf320c0

when executing this command :
yarn run android after yarn start

I have installed the dependencies with yarn, setup my IDE to run JDK15 (and tried JDK1.8 before that, and JDK18 before that). I've been able to build the project (gradle build) but not launching it. Your advices / tests / PR review would be welcome.

@hpelitebook745G2
Copy link

I also got this warning:

LogBox.js:173 EventEmitter.removeListener('deviceEventName', ...): Method has been deprecated. Please instead use remove() on the subscription returned by EventEmitter.addListener. at SwipeButton

@UdaySravanK
Copy link
Owner

This issue has been addressed in the latest patch release v1.3.8. Thanks for bringing it up.

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

6 participants