From a1ec345e2a2cdb4ccf255293616ed5e90f519e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Fri, 4 Oct 2024 04:26:29 -0700 Subject: [PATCH] refactor(iOS): move RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED to const (#46833) Summary: This PR moves `RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED` as it was used as string in the codebase and in OSS libraries. ## Changelog: [IOS] [FIXED] - move RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED to const Pull Request resolved: https://github.com/facebook/react-native/pull/46833 Test Plan: CI Green Reviewed By: cipolleschi Differential Revision: D63891220 Pulled By: javache fbshipit-source-id: d4fa1f751b4b0cb131ab6c6d4dd0a345762d7c71 --- packages/react-native/React/Base/RCTConstants.h | 2 ++ packages/react-native/React/Base/RCTConstants.m | 3 +++ packages/react-native/React/CoreModules/RCTEventDispatcher.mm | 2 +- .../ComponentViews/ScrollView/RCTScrollViewComponentView.mm | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-native/React/Base/RCTConstants.h b/packages/react-native/React/Base/RCTConstants.h index 289e8a09033..f1378009111 100644 --- a/packages/react-native/React/Base/RCTConstants.h +++ b/packages/react-native/React/Base/RCTConstants.h @@ -14,6 +14,8 @@ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollec RCT_EXTERN NSString *const RCTWindowFrameDidChangeNotification; +RCT_EXTERN NSString *const RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED; + /** * This notification fires when the bridge initializes. */ diff --git a/packages/react-native/React/Base/RCTConstants.m b/packages/react-native/React/Base/RCTConstants.m index 70e94ca6b65..656f4bde456 100644 --- a/packages/react-native/React/Base/RCTConstants.m +++ b/packages/react-native/React/Base/RCTConstants.m @@ -21,6 +21,9 @@ NSString *const RCTJavaScriptWillStartLoadingNotification = @"RCTJavaScriptWillS NSString *const RCTDidInitializeModuleNotification = @"RCTDidInitializeModuleNotification"; +NSString *const RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED = + @"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"; + /* * W3C Pointer Events */ diff --git a/packages/react-native/React/CoreModules/RCTEventDispatcher.mm b/packages/react-native/React/CoreModules/RCTEventDispatcher.mm index 36082d18200..6517cb15db6 100644 --- a/packages/react-native/React/CoreModules/RCTEventDispatcher.mm +++ b/packages/react-native/React/CoreModules/RCTEventDispatcher.mm @@ -58,7 +58,7 @@ RCT_EXPORT_MODULE() NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(_notifyEventDispatcherObserversOfEvent_DEPRECATED:) - name:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED" + name:RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED object:nil]; } diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index e47c62e131d..4ac6fcf763f 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -74,7 +74,7 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrollView, NSInt userData:nil coalescingKey:coalescingKey]; NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:scrollEvent, @"event", nil]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED" + [[NSNotificationCenter defaultCenter] postNotificationName:RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED object:nil userInfo:userInfo]; }