Skip to content
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

FAB.Group actions accepts a IconSource, not only a string #1055

Closed
Grohden opened this issue May 7, 2019 · 5 comments · Fixed by #1057
Closed

FAB.Group actions accepts a IconSource, not only a string #1055

Grohden opened this issue May 7, 2019 · 5 comments · Fixed by #1057

Comments

@Grohden
Copy link

Grohden commented May 7, 2019

Environment

"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:

actions: Array<{
icon: string,
label?: string,
color?: string,
accessibilityLabel?: string,
style?: any,
onPress: () => mixed,
}>,

But the signature is wrong, looking at the FAB.Group source, the action list actually can receive a IconSource just like the normal FAB:

<FAB
small
icon={it.icon}
color={it.color}
style={[

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

@raajnadar
Copy link
Collaborator

The FAB component only supports string even in FAB group because the FAB group used the FAB component as a child element. So the compiler is doing its job correctly.

Note paper only supports icon from material.io in v3 they are planning to add custom fonts support.

@Grohden
Copy link
Author

Grohden commented May 8, 2019

You mean the FAB component from the link above? Looking at the source it's declared that it supports a IconSource and not specifically a string

@satya164
Copy link
Member

satya164 commented May 8, 2019

Yes, it supports IconSource. PR welcome to fix it.

@Taym95
Copy link
Collaborator

Taym95 commented May 8, 2019

I would like to fix this issue!

@Grohden
Copy link
Author

Grohden commented May 8, 2019

@Taym95 if you want to fix ok, else I could do it but it will take some days till I get some time for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants