react / react/react-native

Updating App Properties is not available on the ReactSurface interface

Aperta
#54,075 6 commenti 5 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Needs: Triage :mag:
Lingua principale
C++
Stelle
127k
Fork
25.3k
Merge medio
1g 23h
PR unite (30g)
4

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’interfaccia ReactSurface e confronta il comportamento di ReactSurfaceImpl, ReactDelegate e ReactRootView relativamente a appProperties e updateInitProps. Esegui la ReproducerApp obbligatoria per confermare il comportamento attuale di new-architecture. Il lavoro è completato quando il modo supportato per aggiornare le proprietà della view è esposto o documentato chiaramente senza richiedere un downcast dell’implementazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, kotlin, react-native
Ambito
api, mobile
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.