Refactor Image to log component stacktraces for images rendering non-fb sources

Summary:
This diff refactors the Image component in order to log the component hierarchy stacktraces for images rendering non-fb sources

changelog: [internal] internal

Reviewed By: yungsters

Differential Revision: D29266451

fbshipit-source-id: 826230b1a18a5809b340ef0767d80a281e20477a
This commit is contained in:
David Vacca 2021-06-21 20:28:10 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 130b0f69ee
Коммит 7f117394af
3 изменённых файлов: 33 добавлений и 16 удалений

Просмотреть файл

@ -13,7 +13,7 @@ import ImageViewNativeComponent from './ImageViewNativeComponent';
import * as React from 'react';
import StyleSheet from '../StyleSheet/StyleSheet';
import TextAncestor from '../Text/TextAncestor';
import ImageSourceInjection from './ImageSourceInjection';
import ImageInjection from './ImageInjection';
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
import flattenStyle from '../StyleSheet/flattenStyle';
import resolveAssetSource from './resolveAssetSource';
@ -136,8 +136,6 @@ let Image = (props: ImagePropsType, forwardedRef) => {
const uri = source.uri;
if (uri === '') {
console.warn('source.uri should not be an empty string');
} else if (ImageSourceInjection.unstable_enableUriAnalytics) {
ImageSourceInjection.unstable_enableUriAnalytics(uri);
}
}
@ -222,6 +220,10 @@ Image = React.forwardRef<
| React.ElementRef<typeof ImageViewNativeComponent>,
>(Image);
if (ImageInjection.unstable_createImageComponent != null) {
Image = ImageInjection.unstable_createImageComponent(Image);
}
Image.displayName = 'Image';
/**

Просмотреть файл

@ -0,0 +1,28 @@
/**
* 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 strict-local
* @flow
*/
import * as React from 'react';
import type {ImageProps as ImagePropsType} from './ImageProps';
import ImageViewNativeComponent from './ImageViewNativeComponent';
import TextInlineImageNativeComponent from './TextInlineImageNativeComponent';
export default {
unstable_createImageComponent: (null: ?(
Image: React.AbstractComponent<
ImagePropsType,
| React.ElementRef<typeof TextInlineImageNativeComponent>
| React.ElementRef<typeof ImageViewNativeComponent>,
>,
) => React.AbstractComponent<
ImagePropsType,
| React.ElementRef<typeof TextInlineImageNativeComponent>
| React.ElementRef<typeof ImageViewNativeComponent>,
>),
};

Просмотреть файл

@ -1,13 +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
*/
export default {
unstable_enableUriAnalytics: (null: ?(uri: string) => void),
};