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

627
Views
¿Cómo arreglar el elemento vinculante 'hijos' implícitamente tiene un tipo 'cualquiera'.ts (7031)?

Me falta algo aquí con la validación. ¿Cómo agregar tipos de validación? Tener el error "el elemento 'hijos' implícitamente tiene un tipo 'cualquiera'".

 import * as React from 'react'; import Button from './Styles'; const Button1 = ({ children, ...props }) => ( <Button {...props}>{children}</Button> ); Button1.propTypes = {}; export default Button1;
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Sí, le falta un tipo para Props en su conjunto, lo que significa que TypeScript lo ve como any y sus reglas ts no lo permiten.

Tienes que escribir tus props como:

 import React, { FC } from "react"; interface Props { // any props that come into the component } const Button1: FC<Props> = ({ children, ...props }) => ( <Button {...props}>{children}</Button> );
over 4 years ago · Santiago Trujillo Report

0

También puede agregar el tipo predefinido a sus componentes funcionales de esta manera:

 const Button1: React.FC<{}> = ({ children }) => ( <Button>{children}</Button> );

De esta manera, no tienes que repetirte para definir accesorios para children .

La versión más completa podría ser así:

 interface Props { // any other props that come into the component, you don't have to explicitly define children. } const Button: React.FC<Props> = ({ children, ...props }) => { return ( <Button {...props}>{children}</Button> ); };

Tenga en cuenta que funciona para React 16.8

over 4 years ago · Santiago Trujillo Report

0

Este fue un problema importante para mí y perdí mucho tiempo para encontrar la solución correcta. En este momento, tiene un error con los accesorios para niños, pero en el futuro, es posible que tenga este error para muchas funciones en las que está desestructurando los parámetros. Por lo tanto, sugeriría seguir este problema de GitHub.

 const yourfunc = ({destructuredProps}: {destructuredProps: type}) => {}
over 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!