Skip to content

Commit 2187daa

Browse files
Amwamalvaromb
authored andcommitted
Fix flow errors (#101)
1 parent 4d065d7 commit 2187daa

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/KeyboardAwareMixin.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { PropTypes } from 'react'
44
import ReactNative, { TextInput, Keyboard, UIManager } from 'react-native'
55
import TimerMixin from 'react-timer-mixin'
66

7+
import type { Event } from 'react-native'
8+
79
const _KAM_DEFAULT_TAB_BAR_HEIGHT: number = 49
810
const _KAM_KEYBOARD_OPENING_TIME: number = 250
911
const _KAM_EXTRA_HEIGHT: number = 75
@@ -127,15 +129,21 @@ const KeyboardAwareMixin = {
127129
/**
128130
* @param extraHeight: takes an extra height in consideration.
129131
*/
130-
scrollToFocusedInput: function (reactNode: Object, extraHeight: number = this.props.extraHeight) {
132+
scrollToFocusedInput: function (reactNode: Object, extraHeight: number) {
133+
if (extraHeight === undefined) {
134+
extraHeight = this.props.extraHeight;
135+
}
131136
this.setTimeout(() => {
132137
this.getScrollResponder().scrollResponderScrollNativeHandleToKeyboard(
133138
reactNode, extraHeight, true
134139
)
135140
}, _KAM_KEYBOARD_OPENING_TIME)
136141
},
137142

138-
scrollToFocusedInputWithNodeHandle: function (nodeID: number, extraHeight: number = this.props.extraHeight) {
143+
scrollToFocusedInputWithNodeHandle: function (nodeID: number, extraHeight: number) {
144+
if (extraHeight === undefined) {
145+
extraHeight = this.props.extraHeight;
146+
}
139147
const reactNode = ReactNative.findNodeHandle(nodeID)
140148
this.scrollToFocusedInput(reactNode, extraHeight + this.props.extraScrollHeight)
141149
},
@@ -144,7 +152,7 @@ const KeyboardAwareMixin = {
144152

145153
defaultResetScrollToCoords: null, // format: {x: 0, y: 0}
146154

147-
handleOnScroll: function (e) {
155+
handleOnScroll: function (e: Event) {
148156
this.position = e.nativeEvent.contentOffset
149157
},
150158
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"lint": "eslint lib",
8-
"test": "npm run lint"
8+
"test": "npm run lint",
9+
"flow": "flow check"
910
},
1011
"repository": {
1112
"type": "git",
@@ -39,6 +40,7 @@
3940
"devDependencies": {
4041
"babel-eslint": "^6.0.4",
4142
"eslint": "^3.17.1",
42-
"eslint-plugin-react": "^6.10.0"
43+
"eslint-plugin-react": "^6.10.0",
44+
"flow-bin": "0.33.0"
4345
}
4446
}

0 commit comments

Comments
 (0)