facebook / react-native

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

[v0.74.1]Cursor prop is causing crash on Text #44559

Open alantoa opened 2 months ago

alantoa commented 2 months ago

Description

I have noticed that when I set the cursor: 'pointer' for the Text component, the app breaks, although it works well for View.

https://github.com/facebook/react-native/assets/37520667/46f7f6dd-d33f-42cd-b832-e81e9d0a859f

Steps to reproduce

Set the cursor: 'pointer' style prop for the Text component in react-native.

<Text style={{ cursor: "pointer" }}>Hey, there!👋</Text>

React Native Version

0.74.1

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1 Pro
  Memory: 266.41 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.5.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.5.1
    path: /usr/local/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK:
    API Levels:
      - "26"
      - "29"
      - "30"
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 33.0.1
      - 34.0.0
    System Images:
      - android-26 | Google APIs Intel x86 Atom_64
      - android-34 | Google Play ARM 64 v8a
    Android NDK: Not Found

Stacktrace or Logs

Exception thrown while executing UI block: -[RCTTextView setCursor:]: unrecognized selector sent to instance 0x1082f4290

__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke
    RCTUIManager.m:1165
__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.143
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_drain
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_sim
0x0
0x0

Reproducer

https://snack.expo.dev/@alantoa/cursor-prop-is-causing-crash-on-text

Screenshots and Videos

https://github.com/facebook/react-native/assets/37520667/46f7f6dd-d33f-42cd-b832-e81e9d0a859f

alantoa commented 2 months ago

Hey @Saadnajmi, I know that the cursor prop feature is your contribution, and thank you for your great PR!

I understand that maybe it is unnecessary to set it for Text in VisionOS, but sometimes we need to use it for RN Web. So I'm wondering if we can just ignore this prop on Text instead of throwing an error?

Saadnajmi commented 2 months ago

EDIT: Fix onto main, which I guess can be picked if it lands? https://github.com/facebook/react-native/pull/44563

Ah yeah this is a legitimate bug. We should either allow you to set cursor on Text, or filter it out (presumably by not including it in Text's ViewConfig). I can look into what works in a bit.

Initial testing, this only reproes on the old architecture.