facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.74k stars 24.16k forks source link

onPress work one time only #44245

Closed pigeonmal closed 3 months ago

pigeonmal commented 4 months ago

Description

I try to create my bottom sheet. onPress work only one time, when pressable component is in root. Sometimes it's just the first time click, sometimes is after many clicks, and after does not work anymore. onPressIn work perfectly

The bug is on v0.73.7 (new arch, bridgless false) and v0.74.0 (new arch, bridgless true), tested only on Android.

Steps to reproduce

(TEST ON ANDROID, v0.73.7, and v0.74.0, new arch)

  1. Create component (BottomOption), that show only with state true, with pressable for testing
  2. In App component, add BottomOption inside GestureHandlerRootView.
  3. Click pressable inside screen, that change visible state of BottomOption.
  4. Try click pressable of BottomOption.

React Native Version

0.74.0

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: Windows 10 10.0.19045
  CPU: "(2) x64 AMD Athlon Silver 3050U with Radeon Graphics   "
  Memory: 426.10 MB / 3.42 GB
Binaries:
  Node:
    version: 18.19.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 10.2.4
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found
Languages:
  Java: 17.0.10
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.0
    wanted: 0.74.0
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

No crash or failure in logs

I try debug onPress call with console.log("TEST");

as onPress doesn't call, console.log too.

Reproducer

github.com/pigeonmal/react-native-onpress-bug

Screenshots and Videos

This is video of my app. Normally it's like the reproducer.

https://github.com/facebook/react-native/assets/40658543/408b7987-8291-4c71-a465-ec481ade907b

github-actions[bot] commented 4 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
mensonones commented 4 months ago

Descrição

Tento criar minha folha de baixo. onPress funciona apenas uma vez, quando o componente pressionável está na raiz. Às vezes é apenas o primeiro clique, às vezes depois de muitos cliques e depois não funciona mais. onPressIn funciona perfeitamente

O bug está na v0.73.7 (novo arco, bridgless falso) e v0.74.0 (novo arco, bridgless verdadeiro), testado apenas no Android.

Passos para reproduzir

(TESTE NO ANDROID, v0.73.7 e v0.74.0, novo arco)

  1. Criar componente (BottomOption), que mostra apenas com estado verdadeiro, com pressionável para teste
  2. No componente App, adicione BottomOption dentro de GestureHandlerRootView.
  3. Clique em pressionável dentro da tela, que altera o estado visível de BottomOption.
  4. Tente clicar pressionável em BottomOption.

Versão nativa do React

0,74,0

Plataformas afetadas

Tempo de execução - Android

Saída denpx react-native info

System:
  OS: Windows 10 10.0.19045
  CPU: "(2) x64 AMD Athlon Silver 3050U with Radeon Graphics   "
  Memory: 426.10 MB / 3.42 GB
Binaries:
  Node:
    version: 18.19.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 10.2.4
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found
Languages:
  Java: 17.0.10
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.0
    wanted: 0.74.0
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace ou registros

No crash or failure in logs

I try debug onPress call with console.log("TEST");

as onPress doesn't call, console.log too.

Reprodutor

github.com/pigeonmal/react-native-onpress-bug

Capturas de tela e vídeos

Este é o vídeo do meu aplicativo. Normalmente é como o reprodutor.

Registro_2024-04-24-22-06-44.mp4

Hey, @pigeonmal! Create a valid reproduction! I tried to adjust some things, but it still couldn't run.

image

876e5210-a590-45ba-b61f-9e245989ee2a

When the example is ok, it will be a pleasure to try to help.

pigeonmal commented 4 months ago

Sorry for the slow response, I finally managed to get the bug in the reproducer.

CHECK: https://github.com/pigeonmal/react-native-onpress-bug/

I have put the same code as my app.

When newArchEnabled=false: NO BUG, pressable work When newArchEnabled=true: BUG, pressable don't work

I don't know for the moment if this a bug in react-native, or in my packages, I must do more tests.

necmettindev commented 3 months ago

I think it is about "react-native-animated" not the react-native.

pigeonmal commented 3 months ago

I try to remove react-native-reanimated, the bug has disappeared