Add TypeScript types to this React component built with Chakra UI import { Fragment,…
- User
Add TypeScript types to this React component built with Chakra UI
import { Fragment, useRef } from 'react'; import { useListBox } from 'react-aria'; import { Box, useMultiStyleConfig, chakra } from '@chakra-ui/react'; import type { MutableRefObject } from 'react'; import type { SelectState } from 'react-stately'; import type { LayoutProps } from '@chakra-ui/styled-system';
import { DropdownOption } from './DropdownOption';
export const DropdownList = ({ maxHeight, listBoxRef, state, ...rest }) => { const ref = useRef(null); const listRef = listBoxRef || ref; const { listBoxProps } = useListBox(rest, state, listRef); const styles = useMultiStyleConfig('Dropdown');
return ( <chakra.ul {...listBoxProps} ref={listRef} maxHeight={`${maxHeight}px`} __css={styles.list}> {[...state.collection].map((item, index) => ( <Fragment key={item.key}> {index !== 0 && <Box my={1} borderBottom="1px solid" borderBottomColor="blue.100" />} <DropdownOption item={item} state={state} /> </Fragment> ))} </chakra.ul> );};
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.