import React from 'react'; import { getCustomMDXComponent } from 'rspress/theme'; const { table, td, tr, th } = getCustomMDXComponent(); // usage // const Table = ({ data }: { data: Array> }) => { if (data.length < 2) { throw new Error('The data length is invalid!'); } const Thead = () => tr({ children: [ data[0].map((row, index) => { const Th = () => th({ children: row, }); return ; }); const TableCom = table({ children: [ , , ], }); return <>{TableCom}; }; export default Table;
; }), ], }); const Tbody = () => data.slice(1).map((row, index) => { const Tr = () => tr({ children: [ row.map((h, index) => { const Td = () => td({ children: h, }); return ; }), ], }); return