question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onLongPress is not working

See original GitHub issue

Environment

react: 16.9.0 react-native: 0.61.2 react-native-paper: ^2.16.0

Description

Below doesn’t work

<TouchableRipple onLongPress={() => console.log('on long press')}>
 //
</TouchableRipple>

whereas onPress works

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Trancevercommented, Dec 10, 2019

Check this working example. Make sure to also pass onPress.

0reactions
lordjackcommented, Jun 2, 2021

For my work normally, It’s my example.

` <List.Section> {this.state.contatoList.map((item, i) => ( <>

                    <TouchableOpacity
                        onLongPress={() => {
                            Alert.alert(
                                'Remover Usuário',
                                'Deseja realmente remover o registro?',
                                [
                                    {
                                        text: 'Cancel',
                                        onPress: () => console.log('Cancel Pressed'),
                                        style: 'cancel',
                                    },
                                    {
                                        text: 'OK',
                                        onPress: () => this.remover(item.id),
                                    },
                                ],
                                { cancelable: false }
                            );
                        }}
                        onPress={() => {
                            let objContato = {
                                id: item.id,
                                nome: item.nome,
                                telefone: item.telefone,
                                dataNascimento: item.dataNascimento,
                            };
                            this.props.navigation.navigate("Formulário Contato", {
                                contato: objContato,
                                contatos: this.state.contatoList,
                            });
                        }}
                    >

                        <Divider />
                        <Paragraph>{i + 1}</Paragraph>
                        <Title>{item.nome}</Title>
                        <Paragraph>{item.telefone}</Paragraph>
                        <Paragraph>{item.dataNascimento}</Paragraph>
                        <Divider />
                    </TouchableOpacity>

                </>
            ))}

</List.Section> `

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - onLongPress is not working same as onClick
I have used useState for both. When I long press the item it opens the menu but again if I Long press the...
Read more >
onLongPress is not working same as onClick : r/reactnative
I am passing onLongPress on a Component which has same function as onClick. I have used useState for both . When I long...
Read more >
Handling Touches - React Native
These long presses can be handled by passing a function to the onLongPress props of any of the "Touchable" components. Let's see all...
Read more >
Add LongPress on Button using TouchableOpacity Example
Example to use longpress on button using TouchableOpacity in React Native.
Read more >
onLongPress | VueUse
Listen for a long press on an element. Function provides modifiers in options. stop; once; prevent; capture; self. Demo #. source. Long Pressed:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found