mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
UIManagerJSInterface: Fix getConstantsForViewManager types
Summary: If Flow can be trusted, getConstantsForViewManager always gets called with a non-null string: 1. The only call-site to getConstantsForViewManager is getViewManagerConfig: [PaperUIManager.js](https://github.com/facebook/react-native/blob/822bf52c29729d25b2bfb31655cf773609a9283d/packages/react-native/Libraries/ReactNative/PaperUIManager.js#L36-L80) 2. And getViewManagerConfig always passes in a non-null string. So, let's just make the native argument type a non-nullable string. Thoughts? Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D52628937 fbshipit-source-id: 0ca68b38253cf134af29974af9e36380d66895a1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4636029aca
commit
d11dca7ba3
@@ -41,7 +41,7 @@ const getUIManagerConstantsCached = (function () {
|
||||
};
|
||||
})();
|
||||
|
||||
const getConstantsForViewManager: ?(viewManagerName: string) => Object =
|
||||
const getConstantsForViewManager: ?(viewManagerName: string) => ?Object =
|
||||
global.RN$LegacyInterop_UIManager_getConstantsForViewManager;
|
||||
|
||||
const getDefaultEventTypes: ?() => Object =
|
||||
@@ -157,7 +157,7 @@ const UIManagerJSUnusedAPIs = {
|
||||
|
||||
const UIManagerJSPlatformAPIs = Platform.select({
|
||||
android: {
|
||||
getConstantsForViewManager: (viewManagerName: string): Object => {
|
||||
getConstantsForViewManager: (viewManagerName: string): ?Object => {
|
||||
if (getConstantsForViewManager) {
|
||||
return getConstantsForViewManager(viewManagerName);
|
||||
}
|
||||
|
||||
+2
-3
@@ -247,9 +247,8 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
}
|
||||
|
||||
@ReactMethod(isBlockingSynchronousMethod = true)
|
||||
public @Nullable WritableMap getConstantsForViewManager(@Nullable String viewManagerName) {
|
||||
ViewManager targetView =
|
||||
viewManagerName != null ? mUIImplementation.resolveViewManager(viewManagerName) : null;
|
||||
public @Nullable WritableMap getConstantsForViewManager(String viewManagerName) {
|
||||
ViewManager targetView = mUIImplementation.resolveViewManager(viewManagerName);
|
||||
if (targetView == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ export interface Spec extends TurboModule {
|
||||
) => void;
|
||||
|
||||
// Android only
|
||||
+getConstantsForViewManager?: (viewManagerName: string) => Object;
|
||||
+getConstantsForViewManager?: (viewManagerName: string) => ?Object;
|
||||
+getDefaultEventTypes?: () => Array<string>;
|
||||
+setLayoutAnimationEnabledExperimental?: (enabled: boolean) => void;
|
||||
+sendAccessibilityEvent?: (reactTag: ?number, eventType: number) => void;
|
||||
|
||||
Reference in New Issue
Block a user