Handwritten view configs for Image

Summary:
Hand writing view configs for NativeImageViewComponent so that it'll work in bridgeless mode and won't fall back to the UIManager.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D19217961

fbshipit-source-id: d5a123b35a75ba3e22c57b1dde18a47893681614
This commit is contained in:
Peter Argany
2020-01-07 14:46:11 -08:00
committed by Facebook Github Bot
parent 233fdfc014
commit 80cfa9c8ee
4 changed files with 83 additions and 14 deletions
+8 -7
View File
@@ -12,8 +12,6 @@
const requireNativeComponent = require('../ReactNative/requireNativeComponent');
import codegenNativeComponent from '../Utilities/codegenNativeComponent';
import type {DangerouslyImpreciseStyle} from '../StyleSheet/StyleSheet';
import type {ResolvedAssetSource} from './AssetSourceResolver';
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
@@ -22,6 +20,9 @@ import type {ViewProps} from '../Components/View/ViewPropTypes';
import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
import type {ColorValue} from '../StyleSheet/StyleSheetTypes';
import ImageViewViewConfig from './ImageViewViewConfig';
const ReactNativeViewConfigRegistry = require('../Renderer/shims/ReactNativeViewConfigRegistry');
type NativeProps = $ReadOnly<{|
...ImageProps,
...ViewProps,
@@ -40,15 +41,15 @@ type NativeProps = $ReadOnly<{|
|}>;
let ImageViewNativeComponent;
if (global.RN$Bridgeless) {
ImageViewNativeComponent = codegenNativeComponent<NativeProps>(
'RCTImageView',
);
ReactNativeViewConfigRegistry.register('RCTImageView', () => {
return ImageViewViewConfig;
});
ImageViewNativeComponent = 'RCTImageView';
} else {
ImageViewNativeComponent = requireNativeComponent<NativeProps>(
'RCTImageView',
);
}
module.exports = (ImageViewNativeComponent: HostComponent<NativeProps>);
export default ((ImageViewNativeComponent: any): HostComponent<NativeProps>); // flowlint-line unclear-type:off