diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index 84b91beac623..ea065c61a9be 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -333,14 +333,15 @@ function BaseSelectionList( isFocused, }); + const selectedItemIndex = useMemo(() => flattenedSections.allOptions.findIndex((option) => option.isSelected), [flattenedSections.allOptions]); + useEffect(() => { - const selectedItemIndex = flattenedSections.allOptions.findIndex((option) => option.isSelected); if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex) { return; } setFocusedIndex(selectedItemIndex); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps - }, [flattenedSections]); + }, [selectedItemIndex]); const clearInputAfterSelect = useCallback(() => { onChangeText?.('');