Skip to content

[0.74.0-rc.1] Invariant violation when accessing TurboModules #43213

Description

@tido64

Old Version

0.73.4

New Version

0.74.0-rc.1

Description

If a New Architecture enabled library implements ReactModuleInfoProvider using a pattern like below:

    override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
        val info = ReactModuleInfo(
            WebStorageModule.NAME,
            WebStorageModule::class.java.name,
            false,
            false,
            false,
            false,
            TurboModule::class.java.isAssignableFrom(WebStorageModule::class.java)  // <-- THIS
        )
        mapOf(info.name() to info).toMutableMap()
    }

It will no longer be detected as a TurboModule because TurboModule::class.java.isAssignableFrom() will now return false. The reason is because the TurboModule class used here is no longer the same TurboModule class used for the generated spec: b7191cd

Quite a number of libraries currently use this pattern: https://github.com/search?q=TurboModule.class.isAssignableFrom&type=code

Steps to reproduce

git clone https://github.com/microsoft/react-native-test-app.git
cd react-native-test-app
npm run set-react-version 0.74 -- --core-only
yarn
cd example
yarn android --extra-params "-PnewArchEnabled=true"

# In a separate terminal
yarn start

Affected Platforms

Runtime - Android, Build - MacOS

Output of npx react-native info

n/a

Stacktrace or Logs

n/a

Reproducer

https://github.com/microsoft/react-native-test-app.git

Screenshots and Videos

n/a

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions