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

204
Vistas
How to get event props in React component with rest operator?

I need some help. I am beginner in TS and i don't know how can i use my event props in my component. I defined two props and i need all my events as rest props.

I got an error when i use my component with onClick event.

Error: Property 'onClick' does not exist on type 'IntrinsicAttributes & ButtonProps'

I will be grateful for any help you can provide.

Here is my component:

export type ButtonProps = {
  children: React.ReactNode;
  className: string;  
};


export const Button = ({ children, className, ...rest }: ButtonProps) => {
  return (
   <button className={className} {...rest}>
     {children}
   </button>
  );
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can do it like this using PropsWithChildren:

import { PropsWithChildren } from "react";

export type ButtonProps = {
  className: string;  
};


export const Button = ({ children, className, ...rest }: PropsWithChildren<ButtonProps>) => {
  return (
   <button className={className} {...rest}>
     {children}
   </button>
  );
};
about 4 years ago · Juan Pablo Isaza 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