Issue
I am trying to defined a props interface for my Component and would like it to include all common attributes.
but found out there are two different interface i can extend
interface MyProps extend React.HTMLProps<HTMLElement>
and
interface MyProps extend React.HTMLAttributes<HTMLElement>
what is the difference? which one should I use? seems like HTMLProps includes HTMLAttributes, does it mean HTMLProps should be a better candidates?
Solution
HTMLProps
contains more stuff than HTMLAttributes
. Stuff like ref
etc.
I've done the following in the past :
export interface PrimitiveProps extends React.HTMLProps<HTMLDivElement> { };
And it has worked out fine for me 🌹
Answered By - basarat
Answer Checked By - - Robin (ReactFix Admin)