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

[0.74] AppRegistry.registerComponent cannot show in a new ReactRooView

Open NiuGuohui opened this issue 1 year ago • 2 comments

Description

Android platform. In some projects, you may need to use ReactRootView to mount components registered through AppRegistry.registerComponent. This method was available in previous versions, but after 0.74, it throws an error:

Invariant Violation: "POPOVER" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called., js engine: hermes

Steps to reproduce

  1. clone repo
  2. run app
  3. click red button
  4. popover was show but its empty
  5. console has an error

React Native Version

0.74.0

Affected Platforms

Runtime - Android

Areas

Fabric - The New Renderer, TurboModule - The New Native Module System, JSI - Javascript Interface, Bridgeless - The New Initialization Flow

Output of npx react-native info

System:
  OS: macOS 14.3.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 176.25 MB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.19.0
    path: ~/.nvm/versions/node/v18.19.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v18.19.0/bin/yarn
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v18.19.0/bin/npm
  Watchman:
    version: 2021.11.15.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.10.1
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 21.4
      - iOS 16.0
      - macOS 12.3
      - tvOS 16.0
      - watchOS 9.0
  Android SDK:
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11567975
  Xcode:
    version: 14.0.1/14A400
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.0
    wanted: 0.74.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

Invariant Violation: "__POPOVER__" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

Reproducer

https://github.com/NiuGuohui/rn0.74-rootviewBug

Screenshots and Videos

No response

NiuGuohui avatar Apr 26 '24 01:04 NiuGuohui

:warning: Add or Reformat Version Info
:information_source: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2

github-actions[bot] avatar Apr 26 '24 01:04 github-actions[bot]

It will be correct when I close bridgelessEnabled.

NiuGuohui avatar Apr 28 '24 08:04 NiuGuohui

I found a solution! Created a view by referring to the ReactDelegate#loadApp method (bridgeless): image

NiuGuohui avatar Jun 04 '24 10:06 NiuGuohui

Created a view by referring to the ReactDelegate#loadApp method (bridgeless):

@NiuGuohui I am running into the original Invariant Violation error when enabling bridgeless on 0.73.7. Can you share how/where exactly you referred to this method? Was this in your MainActivity.kt?

If you have a sample of the code changes needed for the fix, or a repo with the solution, that would be super helpful 🙏 thank you!

raphaeladams avatar Jun 18 '24 14:06 raphaeladams

Created a view by referring to the ReactDelegate#loadApp method (bridgeless):

@NiuGuohui I am running into the original Invariant Violation error when enabling bridgeless on 0.73.7. Can you share how/where exactly you referred to this method? Was this in your MainActivity.kt?

If you have a sample of the code changes needed for the fix, or a repo with the solution, that would be super helpful 🙏 thank you!

For this issue, I was use ReactRootView in my custom native module(seems like wix/react-native-navigation to create multi react container).My MainActivity.kt was created by react-native.You can take a look at this example: https://github.com/NiuGuohui/rn0.74-rootviewBug The problem you encountered might be different from mine if you are not creating the React container in the same way.

NiuGuohui avatar Jun 20 '24 02:06 NiuGuohui