react / react/react-native

Updating App Properties is not available on the ReactSurface interface

Ouverte
#54,075 6 commentaires 5 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Needs: Triage :mag:
Langage dominant
C++
Étoiles
127k
Forks
25.3k
Merge moyen
1 j 23 h
PR mergées (30 j)
4

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par l’interface ReactSurface et comparez le comportement de ReactSurfaceImpl, ReactDelegate et ReactRootView autour de appProperties et updateInitProps. Exécutez la ReproducerApp obligatoire pour confirmer le comportement actuel de new-architecture. Le travail est terminé lorsque la manière prise en charge de mettre à jour les propriétés de la vue est exposée ou clairement documentée sans nécessiter de downcast de l’implémentation.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
android, kotlin, react-native
Domaine
api, mobile
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.