react / react/react-native

Updating App Properties is not available on the ReactSurface interface

Đang mở
#54,075 6 bình luận 5 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Needs: Triage :mag:
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Description

Situation

As an app developer for one of Europe's largest theme parks, I'm tasked with migrating our RN projects to the new architecture.
For our apps we use an in-house developed navigation library that, amongst other things, allows us to update the properties of native views.

Old Architecture

In the old architecture, we were able to read and update the appProperties property on the ReactRootView of the ReactDelegate that we create.

New Architecture

In the new architecture, the ReactRootView property still exists on the ReactDelegate, but will raise SoftExceptions when it tries to update properties that have been left purposefully unimplemented, as the new architecture will just use the Fabric renderer.

In order to still be able to update the properties dynamically we have implemented a workaround that creates and holds a reference to the ReactSurface, set this on the ReactDelegate and explicitly downcast to ReactSurfaceImpl so we can call the updateInitProps function.

... (subclass of android.fragment.app.Fragment)

private var surface: ReactSurface? = null

... (in onCreateView of a Fragment)

surface = reactDelegate.reactHost?.createSurface(  
  requireActivity(),  
  "OurModuleName",  
  injectSailorProps(cachedProps)  
) 
reactDelegate.setReactSurface(surface)

...

fun updateReactProperties(newProperties: Bundle) {
  (surface **as? ReactSurfaceImpl**)?.updateInitProps(newProperties)
}

This downcast is undesirable as its implementation might change at any given point between RN versions.

Question / Request

Is this the envisioned way to update the view properties in the new architecture?
If so, we would like to request the updateInitProps() function to be added to the ReactSurface interface.
If not, please enlighten us on the proper way to update view properties.

Steps to reproduce

Try to call the
ReactRootView.appProperties = bundleOf() (might require actual properties rather than an empty bundle)
with the new architecture and notice the soft exceptions that get raised. Follow the stack trace to see that these methods have been purposefully left unimplemented.
Use the downcast of ReactSurface to actually update the properties when new arch is enabled

React Native Version

0.81.4

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.6.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 150.58 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.6.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 4.9.2
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.5.1
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2025.08.11.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/sjorsdehaas/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.0
      - iOS 26.0
      - macOS 26.0
      - tvOS 26.0
      - visionOS 26.0
      - watchOS 26.0
  Android SDK:
    API Levels:
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 29.0.2
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-28 | Google ARM64-V8a Play ARM 64 v8a
      - android-29 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Google Play Tablet ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13840223
  Xcode:
    version: 26.0.1/17A400
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.16
    path: /usr/bin/javac
  Ruby:
    version: 3.3.0
    path: /Users/sjorsdehaas/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.1
    wanted: ^20.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.4
    wanted: 0.81.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
[ReactNative Architecture][JS] 'updateView' is not available in the new React Native architecture. 
anonymous @ 10.0.2.2:8081/index.…ths=url-server:1187
overrideMethod @ 10.0.2.2:8081/index.…hs=url-server:43436
reactConsoleErrorHandler @ 10.0.2.2:8081/index.…hs=url-server:23987
anonymous @ 10.0.2.2:8081/index.…hs=url-server:50663
raiseSoftError @ 10.0.2.2:8081/index.…ths=url-server:7300
updateView @ 10.0.2.2:8081/index.…ths=url-server:7349
commitTextUpdate @ 10.0.2.2:8081/index.…hs=url-server:79154
runWithFiberInDEV @ 10.0.2.2:8081/index.…hs=url-server:78361
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83296
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83265
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83265
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83265
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83384
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83384
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83265
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83265
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83384
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83384
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83249
recursivelyTraverseMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:83239
commitMutationEffectsOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83304
flushMutationEffects @ 10.0.2.2:8081/index.…hs=url-server:84366
commitRoot @ 10.0.2.2:8081/index.…hs=url-server:84346
commitRootWhenReady @ 10.0.2.2:8081/index.…hs=url-server:83913
performWorkOnRoot @ 10.0.2.2:8081/index.…hs=url-server:83901
performSyncWorkOnRoot @ 10.0.2.2:8081/index.…hs=url-server:79783
flushSyncWorkAcrossRoots_impl @ 10.0.2.2:8081/index.…hs=url-server:79703
scheduleUpdateOnFiber @ 10.0.2.2:8081/index.…hs=url-server:83824
dispatchSetStateInternal @ 10.0.2.2:8081/index.…hs=url-server:81094
dispatchSetState @ 10.0.2.2:8081/index.…hs=url-server:81066
anonymous @ 10.0.2.2:8081/index.…s=url-server:102273
MANDATORY Reproducer

https://github.com/sjorsdehaas-efteling/app-properties-update/tree/main/ReproducerApp

Screenshots and Videos

Purposefully unimplemented methods due to OSS / New Arch:

Image

SoftExceptions in devtools:

Image

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với interface ReactSurface và so sánh hành vi của ReactSurfaceImpl, ReactDelegate và ReactRootView liên quan đến appProperties và updateInitProps. Chạy ReproducerApp bắt buộc để xác nhận hành vi hiện tại của new-architecture. Được xem là hoàn tất khi cách được hỗ trợ để cập nhật các thuộc tính của view đã được cung cấp hoặc ghi lại rõ ràng mà không yêu cầu downcast implementation.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, kotlin, react-native
Lĩnh vực
api, mobile
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.