Antd cannot use the onclick event and style property when using ts,List.Item

<List
        header={<div>list</div>}
        bordered={true}
        dataSource={props.list}
        renderItem={(item, index) => (<List.Item onClick={() => { props.handleItemDelete(index) }}>{item}</List.Item>)}
        style={{ width: "386px", marginTop: "20px" }}
      />
Prompt in

< List

[ts]
"{ header: Element; bordered: true; dataSource: any; renderItem: (item: any, index: any) => Element; style: { width: string; marginTop: string; }; }" "IntrinsicAttributes & IntrinsicClassAttributes<List> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<ListProps>, "footer" | "header" | "id" | "size" | "className" | ... 8 more ... | "locale"> & Partial<...> & Partial<...>" 
  "IntrinsicAttributes & IntrinsicClassAttributes<List> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<ListProps>, "footer" | "header" | "id" | "size" | "className" | ... 8 more ... | "locale"> & Partial<...> & Partial<...>" "style"  [2322]
(alias) class List
import List
Prompt in

< List.Item

[ts]
"{ children: any; onClick: () => void; }" "IntrinsicAttributes & IntrinsicClassAttributes<Item> & Readonly<{ children?: ReactNode; }> & Readonly<ListItemProps>" 
  "IntrinsicAttributes & IntrinsicClassAttributes<Item> & Readonly<{ children?: ReactNode; }> & Readonly<ListItemProps>" "onClick"  [2322]
(alias) class List
import List
Apr.19,2022

List is only used for the presentation of data.
since the onClick attribute is not supported, you can define the event in the child element that you pass to List.Item.


you can bind onClick, and you don't know what the problem is without providing more code.


() = > func ()

Menu