React 组件定义(泛型)

type TProp = (
  props: IProp,
  ref?: React.Ref
) => React.ReactElement | null

const My: TProp = ()=>{}

interface IProp {
  list: RowType[]
  renderItem: (row: RowType, index: number) => JSX.Element
}

export default forwardRef(My) as (
  props: IProp & {
    ref?: React.Ref
  }
) => JSX.Element

你可能感兴趣的:(typescript)