react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Updating App Properties is not available on the ReactSurface interface

Open sjorsdehaas-efteling opened this issue 3 months ago • 4 comments

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

sjorsdehaas-efteling avatar Oct 07 '25 15:10 sjorsdehaas-efteling

@sjorsdehaas-efteling can you expand more on your use case? It feels a bit weird that you need to update the appProperties... those are supposed to be set when you load the app the first time not to be dynamic.

For things that changes dynamically, you can leverage other mechanisms, such as turbomodules with events...

If you can explain a bit more what you are trying to accomplish, we can advise you on the best path forward.

cipolleschi avatar Oct 09 '25 23:10 cipolleschi

Hi @cipolleschi,

Happy to expand a little on our use cases.

Context

Our app is considered a brownfield implementation. We originally started fully native and later on introduced RN on top of this, like AirBnb. This means that our app does not necessarily consist of 1 RN rootview that manages the whole screen, but rather a native view in which certain elements are managed through RN, each with their own root view. We want to be able to update these views dynamically, for which we used the appProperties in the old architecture.

Example Use Case

Within the app we display a map with points of interest (POI) markers. Clicking on one of these POI markers will show a 'Quickview' banner with the basic information about this POI. Clicking a different POI marker, switches the content of this view to the new POI content by updating the properties of the existing view, rather than creating a new view. This allows for easier transitions and better performance.

sjorsdehaas-efteling avatar Oct 14 '25 14:10 sjorsdehaas-efteling

Hi @cipolleschi,

Have you had a chance to assess our use-case(s)? As mentioned, if there is a different approach to accomplish this, we would be open to adapting our implementation.

Kind regards

sjorsdehaas-efteling avatar Nov 20 '25 14:11 sjorsdehaas-efteling

Hi @cipolleschi,

Have you had a chance to take a look?

Kind regards

sjorsdehaas-efteling avatar Dec 16 '25 14:12 sjorsdehaas-efteling