From 118c77a1b2c1ddf82b3485d9171517e99d39eeec Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 13 Sep 2022 11:53:28 -0300 Subject: [PATCH 1/3] Fix: remove listener for appStatusChange to avoid duplicated events --- src/Root.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Root.tsx b/src/Root.tsx index 6d8ad14e8..7ae219fb5 100644 --- a/src/Root.tsx +++ b/src/Root.tsx @@ -290,8 +290,13 @@ export default () => { } } } - AppState.addEventListener('change', onAppStateChange); - return () => AppState.removeEventListener('change', onAppStateChange); + const subscriptionAppStateChange = AppState.addEventListener( + 'change', + onAppStateChange, + ); + return () => { + subscriptionAppStateChange.remove(); + }; }, [ dispatch, onboardingCompleted, From f8ded3eeb3daf67468d5da46458f74f40febfce9 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 13 Sep 2022 12:05:54 -0300 Subject: [PATCH 2/3] Replace all removeEventListener by remove() --- src/Root.tsx | 4 +--- .../tabs/settings/components/Notifications.tsx | 7 +++++-- src/utils/hooks/useDeeplinks.ts | 9 +++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Root.tsx b/src/Root.tsx index 7ae219fb5..7fa41258a 100644 --- a/src/Root.tsx +++ b/src/Root.tsx @@ -294,9 +294,7 @@ export default () => { 'change', onAppStateChange, ); - return () => { - subscriptionAppStateChange.remove(); - }; + return () => subscriptionAppStateChange.remove(); }, [ dispatch, onboardingCompleted, diff --git a/src/navigation/tabs/settings/components/Notifications.tsx b/src/navigation/tabs/settings/components/Notifications.tsx index e9ba9b1bc..d2c55956e 100644 --- a/src/navigation/tabs/settings/components/Notifications.tsx +++ b/src/navigation/tabs/settings/components/Notifications.tsx @@ -91,8 +91,11 @@ const Notifications = () => { setNotificationValue(notificationsState.pushNotifications); } } - AppState.addEventListener('change', onAppStateChange); - return () => AppState.removeEventListener('change', onAppStateChange); + const subscriptionAppStateChange = AppState.addEventListener( + 'change', + onAppStateChange, + ); + return () => subscriptionAppStateChange.remove(); }, [dispatch, setNotificationValue, notificationsState]); useEffect(() => { diff --git a/src/utils/hooks/useDeeplinks.ts b/src/utils/hooks/useDeeplinks.ts index 3be1c36bc..10d8b0c94 100644 --- a/src/utils/hooks/useDeeplinks.ts +++ b/src/utils/hooks/useDeeplinks.ts @@ -166,10 +166,11 @@ export const useDeeplinks = () => { const urlEventHandler = useUrlEventHandler(); useEffect(() => { - Linking.addEventListener('url', urlEventHandler); - return () => { - Linking.removeEventListener('url', urlEventHandler); - }; + const subscribeLinkingEvent = Linking.addEventListener( + 'url', + urlEventHandler, + ); + return () => subscribeLinkingEvent.remove(); }, [dispatch, urlEventHandler]); const linkingOptions: LinkingOptions = { From 753678f9064095c50f6458170becb7aa5e24a032 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 13 Sep 2022 13:36:37 -0300 Subject: [PATCH 3/3] Updates type react-native --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ab5713693..6d30c89bf 100644 --- a/package.json +++ b/package.json @@ -176,7 +176,7 @@ "@types/lodash.isequal": "4.5.5", "@types/lodash.merge": "4.6.6", "@types/lodash.throttle": "4.1.6", - "@types/react-native": "0.64.19", + "@types/react-native": "0.67.4", "@types/react-native-dotenv": "0.2.0", "@types/react-native-snap-carousel": "3.8.5", "@types/react-redux": "7.1.20", diff --git a/yarn.lock b/yarn.lock index b6971489b..2f0167f32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3316,10 +3316,10 @@ dependencies: "@types/react" "*" -"@types/react-native@0.64.19": - version "0.64.19" - resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.64.19.tgz#2b888c082ad293fa0fa6ae34c5e9457cfb38e50a" - integrity sha512-bT62QhaPvOKFGmlfURIC98ILjUDoIFrc2Bn5EzL3qciZrT91vHwkxFOkuEyQJy+DWaHCa2z3IrtIEJywkGu/Bg== +"@types/react-native@0.67.4": + version "0.67.4" + resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.67.4.tgz#97a8d3cff2a7606f247008e93d9fe2a3879bc84e" + integrity sha512-L81CB6W1m0s7d+TH/loP318+VKPwwjWQBUTVYQ1+lQTWiE5jHxyihgCmd7JbwLICo708FRSDwJW7pJoiZHy6yg== dependencies: "@types/react" "*"