Add imageRef prop to ImageBackground

This commit is contained in:
Alexaner T
2018-07-20 14:11:33 +03:00
parent a5ab4665a8
commit 3f26db8119
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'