Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 91706a1

Browse files
committed
moving to stateless functional components
1 parent 821a4db commit 91706a1

File tree

2 files changed

+90
-21
lines changed

2 files changed

+90
-21
lines changed

.flowconfig

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*.web.js
5+
.*/*.android.js
6+
7+
# Some modules have their own node_modules with overlap
8+
.*/node_modules/node-haste/.*
9+
10+
# Ugh
11+
.*/node_modules/babel.*
12+
.*/node_modules/babylon.*
13+
.*/node_modules/invariant.*
14+
15+
# Ignore react and fbjs where there are overlaps, but don't ignore
16+
# anything that react-native relies on
17+
.*/node_modules/fbjs/lib/Map.js
18+
.*/node_modules/fbjs/lib/fetch.js
19+
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
20+
.*/node_modules/fbjs/lib/ErrorUtils.js
21+
22+
# Flow has a built-in definition for the 'react' module which we prefer to use
23+
# over the currently-untyped source
24+
.*/node_modules/react/react.js
25+
.*/node_modules/react/lib/React.js
26+
.*/node_modules/react/lib/ReactDOM.js
27+
28+
.*/__mocks__/.*
29+
.*/__tests__/.*
30+
31+
.*/commoner/test/source/widget/share.js
32+
33+
# Ignore commoner tests
34+
.*/node_modules/commoner/test/.*
35+
36+
# See https://github.com/facebook/flow/issues/442
37+
.*/react-tools/node_modules/commoner/lib/reader.js
38+
39+
# Ignore jest
40+
.*/node_modules/jest-cli/.*
41+
42+
# Ignore Website
43+
.*/website/.*
44+
45+
[include]
46+
47+
[libs]
48+
node_modules/react-native/Libraries/react-native/react-native-interface.js
49+
50+
[options]
51+
module.system=haste
52+
53+
esproposal.class_static_fields=enable
54+
esproposal.class_instance_fields=enable
55+
56+
munge_underscores=true
57+
58+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
59+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'
60+
61+
suppress_type=$FlowIssue
62+
suppress_type=$FlowFixMe
63+
suppress_type=$FixMe
64+
65+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
66+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
67+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
68+
69+
[version]
70+
0.21.0

components/NavButton.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,14 @@ import React from 'react-native'
33
const {
44
Platform,
55
TouchableOpacity,
6-
Component,
76
View,
87
PropTypes,
98
} = React
109
import styles from '../styles'
1110

12-
export class NavButton extends Component {
13-
static propTypes = {
14-
style: View.propTypes.style,
15-
children: PropTypes.node,
16-
onPress: PropTypes.func,
17-
}
18-
19-
static defaultProps = {
20-
style: {},
21-
}
22-
23-
getNavBarButtonStyles(): Array {
24-
const { style } = this.props
11+
function NavButton(props: Object): React.Element {
12+
const getNavBarButtonStyles = (): Array<Object> => {
13+
const { style } = props
2514
if (Platform.OS === 'ios') {
2615
return [
2716
styles.navBarButtonIOS,
@@ -33,21 +22,31 @@ export class NavButton extends Component {
3322
style,
3423
]
3524
}
36-
return null
25+
return []
3726
}
3827

39-
getTouchable(): React.Element {
40-
const { onPress, children } = this.props
28+
const getTouchable = (): React.Element => {
29+
const { onPress, children } = props
4130
return (
4231
<TouchableOpacity onPress={onPress}>
43-
<View style={this.getNavBarButtonStyles()}>
32+
<View style={getNavBarButtonStyles}>
4433
{children}
4534
</View>
4635
</TouchableOpacity>
4736
)
4837
}
4938

50-
render(): React.Element {
51-
return this.getTouchable()
52-
}
39+
return getTouchable
5340
}
41+
42+
NavButton.propTypes = {
43+
style: View.propTypes.style,
44+
children: PropTypes.node,
45+
onPress: PropTypes.func,
46+
}
47+
48+
NavButton.defaultProps = {
49+
style: {},
50+
}
51+
52+
export { NavButton }

0 commit comments

Comments
 (0)