Implement setNativeProps in component to allow use as a child component in TouchableHighlight, etc.

This commit is contained in:
fei 2016-10-25 10:59:39 -07:00
parent 7f5155bc95
commit 890fd1877b
2 changed files with 10 additions and 1 deletions

View File

@ -10,6 +10,10 @@ export default class LinearGradient extends Component {
...View.propTypes,
};
setNativeProps(props) {
this.c.setNativeProps(props);
}
render() {
const {
children,
@ -44,7 +48,7 @@ export default class LinearGradient extends Component {
];
return (
<View {...otherProps} style={style}>
<View ref={(c) => { this.c = c; }} {...otherProps} style={style}>
<NativeLinearGradient
style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}}
colors={colors.map(processColor)}

View File

@ -14,6 +14,10 @@ export default class LinearGradient extends Component {
...View.propTypes,
};
setNativeProps(props) {
this.c.setNativeProps(props);
}
render() {
const {
colors,
@ -26,6 +30,7 @@ export default class LinearGradient extends Component {
return (
<NativeLinearGradient
ref={(c) => { this.c = c; }}
{...otherProps}
colors={colors.map(processColor)}
locations={locations ? locations.slice(0, colors.length) : null}