No problem, @ashutoshshelke!
I’m not entirely sure why Mosh’s IDE is not throwing an error, but, as @isimmons33 indicated, I would also guess that there was a change in some library’s version update. I tried downgrading to Mosh’s react-icons version (4.7.1), but the error persisted. Following the ctrl+Click rabbit hole @isimmons33 mentioned, I was able to remove the error in another manner.
In Visual Studio Code, if you ctrl+Click the icon name in your import statement, you should be directed to the appropriate line in index.d.ts. From there, if you ctrl+Click the type IconType, you should be directed to the appropriate line in iconBase.d.ts. If you ctrl+Click the prop IconBaseProps in that line, you should be directed to the block of code just above. For me, the block of code looked as follows:
export interface IconBaseProps extends React.SVGAttributes<SVGElement> {
children?: React.ReactNode;
size?: string | number;
color?: string;
title?: string;
}
I was able to clear the onClick error we’re discussing by adding an onClick attribute as follows:
onClick?: React.ReactNode;
The same block of code now looks as follows:
export interface IconBaseProps extends React.SVGAttributes<SVGElement> {
children?: React.ReactNode;
size?: string | number;
color?: string;
title?: string;
onClick?: React.ReactNode;
}
Everything functions as expected (so far).
Being new to React, I’m not sure what the best method is for resolving our error. (I’m sure the “best method” is subjective) If the onClick event no longer exists (or never existed) for icons, I’d rather not add it as I can’t be certain of potential consequences elsewhere. For that reason, I’ll likely resolve to wrapping icons in div tags if I want to pass the icons an onClick event; I’ve been seeing that method (along with other HTML tags like <span> and <a>) in all my research so far.
I’m sorry I don’t have a firm answer to your question, but I hope my response helps!