Skip to content

Conversation

@mrousavy
Copy link
Contributor

@mrousavy mrousavy commented Jan 23, 2026

Summary:

In Nitro, we support creating views using Fabric's view system.

We use StateWrapper (and StateWrapperImpl) from C++. While we can use react::StateWrapperImpl from C++, we had to define StateWrapper ourselves (see JStateWrapper.hpp)

StateWrapperImpl inherits from StateWrapper in Kotlin, but the same inheritance is not reflected in C++ via fbjni.

To fix this, we did some dirty static downcasting, which is not safe to do but worked.

Changelog:

[ANDROID] [ADDED] - Add StateWrapper to C++ fbjni types

Test Plan:

When you have a StateWrapperImpl in Kotlin, pass that to C++ via fbjni using the jni::alias_ref<react::StateWrapper> type. (Example; SimpleViewManager.updateState(...) gives you a StateWrapper)

Then try downcasting via jni::dynamic_ref_cast<react::StateWrapperImpl>(...).

If both works, this PR works.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 23, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants