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

317
Vistas
Type '{ children: Element[]; }' has no properties in common with type 'IntrinsicAttributes' & { className?: string | undefined; }'

I have a simple screen where I use some custom components, but I'm having problems with a ts error:

Type '{ children: Element[]; }' has no properties in common with type 'IntrinsicAttributes & { className?: string | undefined; }'.

in this file where I import my ContentCenterDiv component:

import LoadingIndicator from './LoadingIndicator';
import ErrorIndicator from './ErrorIndicator';
import React from 'react';
import ContentCenterDiv from './ContentCenterDiv';

export default function LoadingAndErrorCentered({ isLoading, isError, error }: { isLoading: boolean, isError: boolean, error: any }) {
    return (
        <ContentCenterDiv>
            <LoadingIndicator isLoading={isLoading} />
            <ErrorIndicator isError={isError} error={error} />
        </ContentCenterDiv>
    );
}

ContentCenterDiv.tsx:

import React from "react";

export default function ContentCenterDiv({ className, ...others }: { className?: string }) {
    return <div {...others} className={`w-100 d-flex flex-column align-items-center ${className}`} />;
}

To be clear, ContentCenterDiv is a 'container', that means, it's the parent element of one or more components.

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

With the props type { className?: string } you specify that ContentCenterDiv has no other props than className, which means it also doesn't have a children prop and therefore won't accept children.

You can either manually specify a children?: ReactNode property in the parameter type, or use the generic type React.PropsWithChildren type to add it:

function ContentCenterDiv({ className, ...others }:
  PropsWithChildren<{ className?: string }>) {
    return <div {...others} className={`w-100 d-flex flex-column align-items-center ${className}`} />;
}

TypeScript playground

almost 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