Skip to content

Commit a428194

Browse files
author
alvaromb
committed
Added small check to focused input
1 parent 7e2603b commit a428194

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/KeyboardAwareMixin.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ const KeyboardAwareMixin = {
1212
propTypes: {
1313
enableAutoAutomaticScroll: PropTypes.bool
1414
},
15-
getDefaultProps: function() {
15+
16+
getDefaultProps: function () {
1617
return {
1718
enableAutoAutomaticScroll: true,
18-
};
19+
}
1920
},
2021

2122
setViewIsInsideTabBar: function (viewIsInsideTabBar: bool) {
@@ -45,7 +46,14 @@ const KeyboardAwareMixin = {
4546
// Automatically scroll to focused TextInput
4647
if (this.props.enableAutoAutomaticScroll) {
4748
const currentlyFocusedField = TextInput.State.currentlyFocusedField()
48-
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
49+
if (!currentlyFocusedField) {
50+
return
51+
}
52+
try {
53+
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
54+
} catch (e) {
55+
56+
}
4957
}
5058
},
5159

0 commit comments

Comments
 (0)