Merge pull request #27435 from a-tarasyuk/feature/add-image-ref-prop-to-image-background

[react-native] - Add imageRef prop to ImageBackground
This commit is contained in:
Eloy Durán
2018-07-20 19:11:11 +02:00
committed by GitHub
2 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -3698,8 +3698,9 @@ export class Image extends ImageBase {
}
export interface ImageBackgroundProps extends ImagePropsBase {
style?: StyleProp<ViewStyle>;
imageStyle?: StyleProp<ImageStyle>;
style?: StyleProp<ViewStyle>;
imageRef?(image: Image): void;
}
declare class ImageBackgroundComponent extends React.Component<ImageBackgroundProps> {}
+20
View File
@@ -28,6 +28,7 @@ import {
ImageLoadEventData,
ImageErrorEventData,
ImageResolvedAssetSource,
ImageBackground,
InteractionManager,
ListView,
ListViewDataSource,
@@ -661,6 +662,25 @@ export class ImageTest extends React.Component {
}
}
export class ImageBackgroundProps extends React.Component {
private _imageRef: Image | null = null;
setImageRef = (image: Image) => {
this._imageRef = image;
}
render() {
return (
<View>
<ImageBackground
source={{ uri: 'https://seeklogo.com/images/T/typescript-logo-B29A3F462D-seeklogo.com.png' }}
imageRef={this.setImageRef}
/>
</View>
);
}
}
class StylePropsTest extends React.PureComponent {
render() {
const uri = 'https://seeklogo.com/images/T/typescript-logo-B29A3F462D-seeklogo.com.png'