Skip to content

Commit

Permalink
BREAKING: Removed support of nested content inside <Image> on Android
Browse files Browse the repository at this point in the history
Summary: Use <ImageBackground> instead.

Reviewed By: yungsters

Differential Revision: D5190170

fbshipit-source-id: 29acf99db9a31351dbfe8eeefa61abd439f8618c
  • Loading branch information
shergin authored and facebook-github-bot committed Sep 18, 2017
1 parent d1372fa commit 3ff463f
Showing 1 changed file with 4 additions and 51 deletions.
55 changes: 4 additions & 51 deletions Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,36 +246,13 @@ var Image = createReactClass({

/**
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
* make `this` look like an actual native component class. Since it can render
* as 3 different native components we need to update viewConfig accordingly
* make `this` look like an actual native component class.
*/
viewConfig: {
uiViewClassName: 'RCTView',
validAttributes: ReactNativeViewAttributes.RCTView,
},

_updateViewConfig: function(props) {
if (props.children) {
this.viewConfig = {
uiViewClassName: 'RCTView',
validAttributes: ReactNativeViewAttributes.RCTView,
};
} else {
this.viewConfig = {
uiViewClassName: 'RCTImageView',
validAttributes: ImageViewAttributes,
};
}
},

componentWillMount: function() {
this._updateViewConfig(this.props);
},

componentWillReceiveProps: function(nextProps) {
this._updateViewConfig(nextProps);
},

contextTypes: {
isInAParentText: PropTypes.bool
},
Expand Down Expand Up @@ -316,27 +293,10 @@ var Image = createReactClass({
loadingIndicatorSrc: loadingIndicatorSource ? loadingIndicatorSource.uri : null,
});

if (nativeProps.children) {
// TODO(6033040): Consider implementing this as a separate native component
const containerStyle = filterObject(style, (val, key) => !ImageSpecificStyleKeys.has(key));
const imageStyle = filterObject(style, (val, key) => ImageSpecificStyleKeys.has(key));
const imageProps = merge(nativeProps, {
style: [imageStyle, styles.absoluteImage],
children: undefined,
});

return (
<View style={containerStyle}>
<RKImage {...imageProps}/>
{this.props.children}
</View>
);
if (this.context.isInAParentText) {
return <RCTTextInlineImage {...nativeProps}/>;
} else {
if (this.context.isInAParentText) {
return <RCTTextInlineImage {...nativeProps}/>;
} else {
return <RKImage {...nativeProps}/>;
}
return <RKImage {...nativeProps}/>;
}
}
return null;
Expand All @@ -347,13 +307,6 @@ var styles = StyleSheet.create({
base: {
overflow: 'hidden',
},
absoluteImage: {
left: 0,
right: 0,
top: 0,
bottom: 0,
position: 'absolute'
}
});

var cfg = {
Expand Down

0 comments on commit 3ff463f

Please sign in to comment.