FAB.Group actions accepts a IconSource, not only a string
See original GitHub issueEnvironment
"react-native-paper": "2.15.0"
and Typescript
Description
I was looking at the docs to see if i could use a custom icon source on the FAB.Group
actions
, but the type for the actions icon is specified as a string:
https://github.com/callstack/react-native-paper/blob/5935fb4c8010f884b407a91bef30a472dafe58a8/src/components/FAB/FABGroup.js#L32-L39
But the signature is wrong, looking at the FAB.Group
source, the action list actually can receive a IconSource
just like the normal FAB
:
https://github.com/callstack/react-native-paper/blob/5935fb4c8010f884b407a91bef30a472dafe58a8/src/components/FAB/FABGroup.js#L283-L287
Reproducible Demo
I think that just a simple component using typescript and a icon source on the actions will give you the compile error:
const MyComponent = () => <Portal>
<FAB.Group
open={ true }
icon={ props => <Icon name='add' { ...props }/> }
actions={ [
{
icon: props => <Icon name='add' { ...props }/>,
label: 'Enviar',
onPress: () => console.log('Pressed add')
}
] }
onStateChange={ () => { } }
onPress={ () => { } }
/>
</Portal>
I managed to make my code compile making a cast (as unknown as FABGroupAction[]
) on the list before using it on the component
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
I would like to fix this issue!
Yes, it supports
IconSource
. PR welcome to fix it.