-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Add typescript typings for Icon names. #1475
Comments
It's currently impossible to statically type icon name since the actual Icon component is defined in runtime. The best way you can achieve it now is to override types for a particular paper component, assuming that you have a list of all icon names. Paper uses // MyIconButton.ts
import { IconButton } from 'react-native-paper'
type IconButtonProps = React.ComponentProps<typeof IconButton> & { icon : 'icon1' | 'icon2' | ...}
export default IconButton as React.ComponentType<IconButtonProps> |
@nandorojo Could you please add a comment in this thread regarding the typing icon prop? #1489 |
Definitely! Thanks for your attention here. |
Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue. |
Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue. |
Describe the feature
Big fan of this awesome library. This is a small suggestion.
If you give an icon an invalid name, you get an error telling you all of the available icon names:
It would be useful if the
icon
prop had Typescript suggestions with the available names.Also, in the error message, it would be useful to add a link to a website that has the available icon names.
Motivation
It's hard to know which icon types are usable while coding. Also, the error message is long, so it slows the logs down a little.
Related Issues
The text was updated successfully, but these errors were encountered: