Skip to content

Commit 4c56006

Browse files
committed
Fix possible exception
1 parent 8859fbf commit 4c56006

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

components/Autocomplete/index.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ class Autocomplete extends Component {
6969
} else {
7070
this.setState({items: [NO_DATA], loading: false});
7171
}
72-
if (this.dropdown) {
73-
this.dropdown.onPress(this.container);
72+
if (this.dropdown.current) {
73+
this.dropdown.current.onPress(this.container);
7474
}
7575
} catch (error) {
7676
throw new Error(error);
@@ -83,8 +83,8 @@ class Autocomplete extends Component {
8383
} else {
8484
this.setState({items: [NO_DATA], loading: false});
8585
}
86-
if (this.dropdown) {
87-
this.dropdown.onPress(this.container);
86+
if (this.dropdown.current) {
87+
this.dropdown.current.onPress(this.container);
8888
}
8989
} catch (error) {
9090
throw new Error(error);
@@ -110,8 +110,8 @@ class Autocomplete extends Component {
110110
});
111111
}
112112

113-
if (this.dropdown) {
114-
this.dropdown.onPress(this.container);
113+
if (this.dropdown.current) {
114+
this.dropdown.current.onPress(this.container);
115115
}
116116
}
117117
}
@@ -144,8 +144,8 @@ class Autocomplete extends Component {
144144
handleBlur() {
145145
clearTimeout(this.timer);
146146
this.setState({loading: false});
147-
if (this.dropdown) {
148-
this.dropdown.close();
147+
if (this.dropdown.current) {
148+
this.dropdown.current.close();
149149
}
150150
}
151151

@@ -198,9 +198,7 @@ class Autocomplete extends Component {
198198
</View>
199199
{items && items.length > 0 && (
200200
<Dropdown
201-
ref={ref => {
202-
this.dropdown = ref;
203-
}}
201+
ref={this.dropdown}
204202
dropdownPosition={0}
205203
data={data ? filteredItems : items}
206204
listHeader={listHeader}

0 commit comments

Comments
 (0)