diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index ac76846ab2e3..1fa63f181dd6 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -85,7 +85,6 @@ function BaseOptionsSelector(props) { const accessibilityRoles = _.values(CONST.ROLE); const [disabledOptionsIndexes, setDisabledOptionsIndexes] = useState([]); - const [sections, setSections] = useState(); const [shouldDisableRowSelection, setShouldDisableRowSelection] = useState(false); const [errorMessage, setErrorMessage] = useState(''); const [value, setValue] = useState(''); @@ -137,12 +136,6 @@ function BaseOptionsSelector(props) { return calcAllOptions; }, [props.sections]); - // eslint-disable-next-line react-hooks/exhaustive-deps - const initialAllOptions = useMemo(() => flattenSections(), []); - const [allOptions, setAllOptions] = useState(initialAllOptions); - const [focusedIndex, setFocusedIndex] = useState(getInitiallyFocusedIndex(initialAllOptions)); - const [focusedOption, setFocusedOption] = useState(allOptions[focusedIndex]); - /** * Maps sections to render only allowed count of them per section. * @@ -165,6 +158,13 @@ function BaseOptionsSelector(props) { [paginationPage, props.sections], ); + // eslint-disable-next-line react-hooks/exhaustive-deps + const initialAllOptions = useMemo(() => flattenSections(), []); + const [sections, setSections] = useState(sliceSections()); + const [allOptions, setAllOptions] = useState(initialAllOptions); + const [focusedIndex, setFocusedIndex] = useState(getInitiallyFocusedIndex(initialAllOptions)); + const [focusedOption, setFocusedOption] = useState(allOptions[focusedIndex]); + /** * Completes the follow-up actions after a row is selected * @@ -346,9 +346,6 @@ function BaseOptionsSelector(props) { [allOptions, sections], ); - // eslint-disable-next-line react-hooks/exhaustive-deps - useEffect(() => setSections(sliceSections()), []); - useEffect(() => { subscribeToEnterShortcut(); subscribeToCtrlEnterShortcut();