diff --git a/Libraries/Image/ImageViewNativeComponent.js b/Libraries/Image/ImageViewNativeComponent.js index 8a6c0b25aab..360491d5e9f 100644 --- a/Libraries/Image/ImageViewNativeComponent.js +++ b/Libraries/Image/ImageViewNativeComponent.js @@ -4,26 +4,24 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format * @flow strict-local + * @format */ 'use strict'; -const requireNativeComponent = require('../ReactNative/requireNativeComponent'); - -import type {DangerouslyImpreciseStyle} from '../StyleSheet/StyleSheet'; import type {ResolvedAssetSource} from './AssetSourceResolver'; -import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; import type {ImageProps} from './ImageProps'; import type {ViewProps} from '../Components/View/ViewPropTypes'; -import type {ImageStyleProp} from '../StyleSheet/StyleSheet'; -import type {ColorValue} from '../StyleSheet/StyleSheet'; +import * as NativeComponentRegistry from '../NativeComponent/NativeComponentRegistry'; +import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; +import type { + ColorValue, + DangerouslyImpreciseStyle, + ImageStyleProp, +} from '../StyleSheet/StyleSheet'; -import ImageViewViewConfig from './ImageViewViewConfig'; -const ReactNativeViewConfigRegistry = require('../Renderer/shims/ReactNativeViewConfigRegistry'); - -type NativeProps = $ReadOnly<{| +type Props = $ReadOnly<{ ...ImageProps, ...ViewProps, @@ -38,19 +36,65 @@ type NativeProps = $ReadOnly<{| headers?: ?string, defaultSrc?: ?string, loadingIndicatorSrc?: ?string, -|}>; +}>; -let ImageViewNativeComponent; -if (global.RN$Bridgeless) { - ReactNativeViewConfigRegistry.register('RCTImageView', () => { - return ImageViewViewConfig; - }); - ImageViewNativeComponent = 'RCTImageView'; -} else { - ImageViewNativeComponent = requireNativeComponent( - 'RCTImageView', - ); -} +const ImageViewNativeComponent: HostComponent = NativeComponentRegistry.get( + 'RCTImageView', + () => ({ + uiViewClassName: 'RCTImageView', + bubblingEventTypes: {}, + directEventTypes: { + topLoadStart: { + registrationName: 'onLoadStart', + }, + topProgress: { + registrationName: 'onProgress', + }, + topError: { + registrationName: 'onError', + }, + topPartialLoad: { + registrationName: 'onPartialLoad', + }, + topLoad: { + registrationName: 'onLoad', + }, + topLoadEnd: { + registrationName: 'onLoadEnd', + }, + }, + validAttributes: { + blurRadius: true, + capInsets: { + diff: require('../Utilities/differ/insetsDiffer'), + }, + defaultSource: { + process: require('./resolveAssetSource'), + }, + defaultSrc: true, + fadeDuration: true, + headers: true, + loadingIndicatorSrc: true, + onError: true, + onLoad: true, + onLoadEnd: true, + onLoadStart: true, + onPartialLoad: true, + onProgress: true, + overlayColor: { + process: require('../StyleSheet/processColor'), + }, + progressiveRenderingEnabled: true, + resizeMethod: true, + resizeMode: true, + shouldNotifyLoadEvents: true, + source: true, + src: true, + tintColor: { + process: require('../StyleSheet/processColor'), + }, + }, + }), +); -// flowlint-next-line unclear-type:off -export default ((ImageViewNativeComponent: any): HostComponent); +export default ImageViewNativeComponent; diff --git a/Libraries/Image/ImageViewViewConfig.js b/Libraries/Image/ImageViewViewConfig.js deleted file mode 100644 index 4f974c463c2..00000000000 --- a/Libraries/Image/ImageViewViewConfig.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -'use strict'; - -import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; -import {type ViewConfig} from '../Renderer/shims/ReactNativeTypes'; - -const ImageViewViewConfig = { - uiViewClassName: 'RCTImageView', - bubblingEventTypes: {}, - directEventTypes: { - topLoadStart: { - registrationName: 'onLoadStart', - }, - topProgress: { - registrationName: 'onProgress', - }, - topError: { - registrationName: 'onError', - }, - topPartialLoad: { - registrationName: 'onPartialLoad', - }, - topLoad: { - registrationName: 'onLoad', - }, - topLoadEnd: { - registrationName: 'onLoadEnd', - }, - }, - validAttributes: { - ...ReactNativeViewViewConfig.validAttributes, - blurRadius: true, - // flowlint-next-line unclear-type:off - capInsets: {diff: (require('../Utilities/differ/insetsDiffer'): any)}, - defaultSource: { - process: require('./resolveAssetSource'), - }, - defaultSrc: true, - fadeDuration: true, - headers: true, - loadingIndicatorSrc: true, - onError: true, - onLoad: true, - onLoadEnd: true, - onLoadStart: true, - onPartialLoad: true, - onProgress: true, - overlayColor: {process: require('../StyleSheet/processColor')}, - progressiveRenderingEnabled: true, - resizeMethod: true, - resizeMode: true, - shouldNotifyLoadEvents: true, - source: true, - src: true, - tintColor: {process: require('../StyleSheet/processColor')}, - }, -}; - -module.exports = (ImageViewViewConfig: ViewConfig);