import React, { type FC, useEffect, useRef } from 'react' import cn from '@/utils/classnames' type OptionListItemProps = { isSelected: boolean onClick: () => void } & React.LiHTMLAttributes const OptionListItem: FC = ({ isSelected, onClick, children, }) => { const listItemRef = useRef(null) useEffect(() => { if (isSelected) listItemRef.current?.scrollIntoView({ behavior: 'instant' }) }, []) return (
  • { listItemRef.current?.scrollIntoView({ behavior: 'smooth' }) onClick() }} > {children}
  • ) } export default React.memo(OptionListItem)