Commit 99b328b
feat: Add
Summary:
In [Nitro](https://nitro.margelo.com), 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`](https://github.com/mrousavy/nitro/blob/main/packages/react-native-nitro-modules/android/src/main/cpp/views/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
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: #55288
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.
Reviewed By: cipolleschi
Differential Revision: D91468294
Pulled By: javache
fbshipit-source-id: 7d5a04ad486c4f6f776020855468f87d0fd0fff0StateWrapper to fbjni typings (#55288)1 parent 680bd5a commit 99b328b
2 files changed
Lines changed: 21 additions & 1 deletion
File tree
- packages/react-native/ReactAndroid/src/main/jni/react
- fabric
- uimanager
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments