Skip to content

Commit

Permalink
Fixed ImageBackground could't be wrapped by Touchable* component
Browse files Browse the repository at this point in the history
  • Loading branch information
patw0929 committed Jul 7, 2017
1 parent 79bf089 commit c71d227
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Libraries/Image/ImageBackground.js
Expand Up @@ -16,6 +16,8 @@ const Image = require('Image');
const React = require('React');
const StyleSheet = require('StyleSheet');
const View = require('View');
const NativeMethodsMixin = require('NativeMethodsMixin');
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');

/**
* Very simple drop-in replacement for <Image> which supports nesting views.
Expand All @@ -41,7 +43,18 @@ const View = require('View');
* AppRegistry.registerComponent('DisplayAnImageBackground', () => DisplayAnImageBackground);
* ```
*/
class ImageBackground extends React.Component {
const ImageBackground = React.createClass({
mixins: [NativeMethodsMixin],

/**
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
* make `this` look like an actual native component class.
*/
viewConfig: {
uiViewClassName: 'UIView',
validAttributes: ReactNativeViewAttributes.UIView
},

render() {
const {children, style, imageStyle, imageRef, ...props} = this.props;

Expand Down Expand Up @@ -70,6 +83,6 @@ class ImageBackground extends React.Component {
</View>
);
}
}
});

module.exports = ImageBackground;

0 comments on commit c71d227

Please sign in to comment.