import React from 'react'; import type { SectionList, SectionListRenderItemInfo } from 'react-native'; import { Dimensions } from 'react-native'; import type { SingleSelectProps } from '.'; import type { BaseOptionListProps } from '../BaseOptionList'; import type { SelectOptionType, SectionType } from '../types'; import Option from './Option'; import { StyledOptionList } from './StyledSingleSelect'; import { deepCompareValue } from '../../../utils/helpers'; type OptionListProps> = Pick< SingleSelectProps, | 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange' | 'value' | 'renderOption' > & { onPress: (value: V | null) => void; sectionListRef?: React.RefObject | null>; } & BaseOptionListProps; const OptionList = >({ keyExtractor, loading, onEndReached, onPress, onQueryChange, sections, renderOption, value, sectionListRef, ...rest }: OptionListProps) => { const renderItem = (info: SectionListRenderItemInfo) => { const { item } = info; const selected = deepCompareValue(item.value, value); const onItemPress = () => { if (value === item.value) { onPress(null); } else { onPress(item.value); } }; return renderOption ? ( renderOption({ ...info, selected, onPress: onItemPress }) ) : (