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

196
Views
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 answers
Answer question

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