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

312
Views
Escriba '{ niños: Elemento[]; }' no tiene propiedades en común con el tipo 'IntrinsicAttributes' & { className?: string | indefinido; }'

Tengo una pantalla simple donde uso algunos componentes personalizados, pero tengo problemas con un error ts:

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

en este archivo donde importo mi componente ContentCenterDiv :

 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}`} />;
}

Para ser claros, ContentCenterDiv es un 'contenedor', lo que significa que es el elemento principal de uno o más componentes.

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Con el tipo de accesorios { className?: string } , especifica que ContentCenterDiv no tiene otros accesorios además de className , lo que significa que tampoco tiene accesorios para children y, por lo tanto, no aceptará niños.

Puede especificar manualmente una propiedad children?: ReactNode en el tipo de parámetro, o usar el tipo genérico React.PropsWithChildren para agregarlo:

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

patio de recreo typescript

almost 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!