Skip to content

Commit 4ddaecd

Browse files
authored
Merge pull request react-native-linear-gradient#123 from cmcewen/fix-flow
Add proper flow types
2 parents c719101 + 8c64dca commit 4ddaecd

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

index.android.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
// @flow
2+
13
import React, { Component, PropTypes } from 'react';
24
import { processColor, requireNativeComponent, StyleSheet, View } from 'react-native';
35

6+
type PropsType = {
7+
start?: Array<number>;
8+
end?: Array<number>;
9+
colors: Array<string>;
10+
locations?: Array<number>;
11+
} & typeof(View);
12+
413
export default class LinearGradient extends Component {
514
static propTypes = {
615
start: PropTypes.arrayOf(PropTypes.number),
@@ -9,9 +18,11 @@ export default class LinearGradient extends Component {
918
locations: PropTypes.arrayOf(PropTypes.number),
1019
...View.propTypes,
1120
};
21+
props: PropsType;
22+
gradientRef: any;
1223

13-
setNativeProps(props) {
14-
this.c.setNativeProps(props);
24+
setNativeProps(props: PropsType) {
25+
this.gradientRef.setNativeProps(props);
1526
}
1627

1728
render() {
@@ -48,7 +59,7 @@ export default class LinearGradient extends Component {
4859
];
4960

5061
return (
51-
<View ref={(c) => { this.c = c; }} {...otherProps} style={style}>
62+
<View ref={(component) => { this.gradientRef = component; }} {...otherProps} style={style}>
5263
<NativeLinearGradient
5364
style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}}
5465
colors={colors.map(processColor)}

index.ios.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import React, { Component, PropTypes } from 'react';
66
import { processColor, requireNativeComponent, View } from 'react-native';
77

8+
type PropsType = {
9+
start?: Array<number>;
10+
end?: Array<number>;
11+
colors: Array<string>;
12+
locations?: Array<number>;
13+
} & typeof(View);
14+
815
export default class LinearGradient extends Component {
916
static propTypes = {
1017
start: PropTypes.arrayOf(PropTypes.number),
@@ -13,9 +20,11 @@ export default class LinearGradient extends Component {
1320
locations: PropTypes.arrayOf(PropTypes.number),
1421
...View.propTypes,
1522
};
23+
props: PropsType;
24+
gradientRef: any;
1625

17-
setNativeProps(props) {
18-
this.c.setNativeProps(props);
26+
setNativeProps(props: PropsType) {
27+
this.gradientRef.setNativeProps(props);
1928
}
2029

2130
render() {
@@ -30,7 +39,7 @@ export default class LinearGradient extends Component {
3039

3140
return (
3241
<NativeLinearGradient
33-
ref={(c) => { this.c = c; }}
42+
ref={(component) => { this.gradientRef = component; }}
3443
{...otherProps}
3544
colors={colors.map(processColor)}
3645
locations={locations ? locations.slice(0, colors.length) : null}

0 commit comments

Comments
 (0)