Using antd+typescript, you want to customize the contents of the List component, but prompt that you need to add the necessary properties

1. When you refer to the antd-pro noticeIcon component, you find that the List component is used in antd-pro and does not provide the necessary properties.

      <List className={styles.list} >
        {data.map((item, i) => {
          const itemCls = classNames(styles.item, {
            [styles.read]: item.read,
          });
          return (
            <List.Item className={itemCls} key={item.key || i} onClick={() => onClick(item)}>
              <List.Item.Meta
                className={styles.meta}
                avatar={item.avatar ? <Avatar className={styles.avatar} src={item.avatar} /> : null}
                title={
                  <div className={styles.title}>
                    {item.title}
                    <div className={styles.extra}>{item.extra}</div>
                  </div>
                }
                description={
                  <div>
                    <div className={styles.description} title={item.description}>
                      {item.description}
                    </div>
                    <div className={styles.datetime}>{item.datetime}</div>
                  </div>
                }
              />
            </List.Item>
          );
        })}
      </List>

in this code, List does not provide dataSource and so on and uses the onClick attribute in List.Item, but it is not available in List.Item "s props.

2. Now that I use typescript to write this code, I will find a lot of errors

.
1 at the List prompt I need to provide the necessary properties
2 prompt me at Item that onClick is not in the props

clipboard.png

3, so how should I solve this problem

Mar.29,2021

https://github.com/ant-design.

<List className={styles.list} dataSource={[]} renderItem={this.renderItem}>
Menu