Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
React Typescript: Extract table to component and pass additional props

I want to create custom components for table, td, tr etc in order to style them in one place. How do I specify the props for this? The following code is my attempt to achieve this but I get a lot of errors saying that the props are not assignable to the type.

import React, { ReactNode, FC } from "react";

interface Props {
  children: ReactNode;
}

const Table: FC<Props & HTMLTableElement> = ({ children, ...rest }) => (
  <table {...rest} className="min-w-full divide-y divide-gray-300">
    {children}
  </table>
);

export default Table;
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Replace your FC<Props & HTMLTableElement> with:

const Table: FC<
  Props &
    React.DetailedHTMLProps<
      React.TableHTMLAttributes<HTMLTableElement>,
      HTMLTableElement
    >
> = ({ children, ...rest }) => (
  <table {...rest} className="min-w-full divide-y divide-gray-300">
    {children}
  </table>
);

Now you should be able to pass all accepted props of <table />.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!