From 4cb0d2f8b5f8922e2d28ded1e3ecfe19a2e33dce Mon Sep 17 00:00:00 2001 From: keplyx Date: Fri, 15 Nov 2019 19:38:43 +0100 Subject: [PATCH] fixed focus repeating every 500ms --- components/CustomHeader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/CustomHeader.js b/components/CustomHeader.js index 837e8d6..9ca3104 100644 --- a/components/CustomHeader.js +++ b/components/CustomHeader.js @@ -43,9 +43,9 @@ export default class CustomHeader extends React.Component { }; componentDidMount() { - if (this.refs.searchInput !== undefined && this.props.shouldFocusSearchBar) { + if (this.refs.searchInput !== undefined && this.refs.searchInput._root !== undefined && this.props.shouldFocusSearchBar) { // does not work if called to early for some reason... - setInterval(() => this.refs.searchInput._root.focus(), 500); + setTimeout(() => this.refs.searchInput._root.focus(), 500); } }