-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FontAwesome: Typescript issue passing props #6564
FontAwesome: Typescript issue passing props #6564
Comments
This comment was marked as outdated.
This comment was marked as outdated.
@jnoren1 can you try my reproducer: https://stackblitz.com/edit/vitejs-vite-tfhpc2?file=src%2FApp.tsx You missed one step |
Wow, I've been using this library for about six years, and I never came across that specific piece of documentation. When we noticed the JSX indicators, we wondered if we could incorporate a custom Icon. Through trial and error it turned out we could, and we just went ahead with it without consulting the documentation. Your approach did indeed solve that issue. Miraculously, it also corrected the button callbacks, which had never quite worked as described. That's fantastic, thank you so much. It opened up another more concerning error though. There is some typescript incompatibility going on with the size property and when forced it gave the following. I've added the callback style now to a lot of code and every single one takes issue with the size....
I hacked it a wrapper function, but that does not seem ideal removeIcon={(i) => (
<FontAwesomeIcon
{...faExProps(i.iconProps)}
key={`${program.id}-${index}`}
icon={faXmarkCircle}
className="ml-2 text-red-400 hover:text-red-950 cursor-pointer"
size={"xl"}
/>
)} export const faExProps = (props: HTMLProps<unknown> | SVGProps<unknown>): { [key: string]: unknown; } => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { size, ...rest } = props as HTMLProps<unknown>;
return rest;
}; |
@jnoren1 that is great. Do you have a suggestion how we could update the Typescript to make it flexible right now as you know its... Right now the Typescript is. /**
* Icon options passed to any icon.
* ComponentProps are props from the owning component.
* AdditionalProps are any custom properties of an icon like SortIcon of the Datatable for example.
*/
export type IconOptions<ComponentProps, AdditionalProps> = AdditionalProps & {
/**
* Icon specific properties.
*/
iconProps: React.HTMLProps<any> | React.SVGProps<any>;
/**
* The element representing the icon.
*/
element: React.ReactNode;
/**
* Properties of the owning component.
*/
props?: ComponentProps;
[key: string]: any;
}; |
@jnoren1 10.6.6 is out if you want to check the new typescript typing? |
Describe the bug
It appears that Chip is not passing the key property down to its children? The following message is caused by the following code.
the following resolves the issue...
I use custom icons all over the place and never need to do this, so I think this is a failing of Chip. Not sure though.
Reproducer
https://stackblitz.com/edit/vitejs-vite-kn9li3?file=src%2FApp.tsx
PrimeReact version
10.6.3
React version
17.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
Chrome Latest
Steps to reproduce the behavior
run code, open console. see error. adding a key to the icon fixes it.
Expected behavior
no warning.
Also, the onRemove function does not seem to work with the custom icon. I expect that to work, but maybe I misunderstand it's purpose.
The text was updated successfully, but these errors were encountered: