Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

210
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda