泛型组件
tsx
interface TableProps<Row> {
header: [];
data: readonly Row[];
}
const Table = <Row extends Record<string, unknown>>(props: TableProps<Row>) => {
return <table></table>;
};
const Table2 = <Row,>(props: TableProps<Row>) => {
return <table></table>;
};
const Table3: <Row extends Record<string, unknown>>(
props: TableProps<Row>
) => React.Element = ({ data, header }) => {
return <table></table>;
};
function Table4<T>(props: TableProps<T>) {
return <table></table>;
}