From 6d300c03bc1cf4c75e98664ee90433be1b1f7397 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Tue, 5 Jul 2022 12:13:32 -0700 Subject: [PATCH] Fix scrollToIndex crash --- src/components/OptionsSelector.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/OptionsSelector.js b/src/components/OptionsSelector.js index d0702369e301..9abf64aa1303 100755 --- a/src/components/OptionsSelector.js +++ b/src/components/OptionsSelector.js @@ -229,12 +229,12 @@ class OptionsSelector extends Component { this.setState({ allOptions: newOptions, focusedIndex: newFocusedIndex, + }, () => { + if (this.state.allOptions.length <= this.state.focusedIndex) { + return; + } + this.scrollToIndex(this.state.focusedIndex); }); - - if (newOptions.length <= newFocusedIndex) { - return; - } - this.scrollToIndex(newFocusedIndex); } componentWillUnmount() {