React-native-paper: FAB.Group onPress not working

Created on 22 Oct 2020  路  4Comments  路  Source: callstack/react-native-paper


Current behaviour

When I Press the FAB.Group onPress event not working.

Expected behaviour

When I press the FAB.Group it should display the log and should change this.state.open so that I can toggle this.state.open on Press.

Code sample

import React, { Component } from 'react';
import {
    View,
} from 'react-native';
import {
    FAB, Provider, Portal
} from 'react-native-paper'

export default class ProductDetail extends Component {
    constructor() {
        super()
        this.state = {
            open: true,
        }
    }
    render() {
        return (
            <View style={styles.homeView}>
                <FAB.Group
                    onStateChange={() => {
                        console.log("State changes")
                    }}
                    onPress={() => {
                        console.log("Pressed")
                        this.setState((prevState) => ({
                            open: !prevState.open
                        }))
                    }}
                    open={this.state.open}
                    icon={this.state.open ? 'calendar-today' : 'plus'}
                    actions={[
                        { icon: 'plus', onPress: () => console.log('Pressed add') },
                        {
                            icon: 'star',
                            label: 'Star',
                            onPress: () => console.log('Pressed star'),
                        },
                        {
                            icon: 'email',
                            label: 'Email',
                            onPress: () => console.log('Pressed email'),
                        },
                        {
                            icon: 'bell',
                            label: 'Remind',
                            onPress: () => console.log('Pressed notifications'),
                        },
                    ]}
                />
            </View>
        )
    }
}

What have you tried

  1. I wrapper FAB.Group in Providerand Portalbut it changes the zIndexand FAB.Group goes under the other components.
  2. I used TouchableOpacityso i can use its onPressattribute but it also makes FAB.Group to go disappear.

Your Environment

| software | version
| ----------------------- | -------
| android | 10
| react-native | 0.63.2
| react-native-paper | 4.2.0
| node | 12.16.3
| npm | 6.14.4
|react-native-vector-icons|7.1.0

Most helpful comment

Sorry to bother, I just placed FAB at the end of the component and its working now.

All 4 comments

Couldn't find version numbers for the following packages in the issue:

  • react-native-vector-icons
  • expo

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 0.63.2, latest: 0.63.3)
  • npm (found: 6.14.4, latest: 6.14.8)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

Couldn't find version numbers for the following packages in the issue:

  • expo

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 0.63.2, latest: 0.63.3)
  • npm (found: 6.14.4, latest: 6.14.8)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

I am not using expo, I am using react-native-cli & also react-native and npmversions are almost same

Sorry to bother, I just placed FAB at the end of the component and its working now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knobandre picture knobandre  路  4Comments

sritharanpalani picture sritharanpalani  路  4Comments

yaronlevi picture yaronlevi  路  3Comments

ferrannp picture ferrannp  路  4Comments

timothystewart6 picture timothystewart6  路  4Comments