react-native-reanimated: 3.0.0-rc.2 Android - TypeError: Cannot read property 'stateNode' of undefined
Description
I’m attempting to use Fabric with 3.0.0-rc.2. iOS works fine however on Android I get the following attempting to render an Animated.View.
ERROR TypeError: Cannot read property 'stateNode' of undefined
This error is located at:
in AnimatedComponent(View) (at createAnimatedComponent.tsx:533)
Steps to reproduce
Render an <Animated.View/>
Snack or a link to a repository
https://github.com/kyle-ssg/reanimated-reproduction
Reanimated version
3.0.0-rc.2
React Native version
0.69.5 (I can confirm this also happens on RN 0.70.rc-4)
Platforms
Android
JavaScript runtime
JSC
Workflow
React Native (without Expo)
Architecture
Fabric (New Architecture)
Build type
Debug mode
Device
Android emulator
Device model
No response
Acknowledgements
Yes
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 26 (4 by maintainers)
Hey @kyle-ssg, any chance you are using @gorhom’s bottom-sheet, too?
Error trace:
@tomekzaw
Running "myapp" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
If someone is running into similar issue (for me it was property ‘version’ of undefined) my solution was to modify properly metro.config.js. I had react-native-svg-transformer included in project as well and you need to follow the new way to integrate it on it’s official github page.
Since yesterday I got my setup working (iOS and android) with quite a few dependencies, including @gorhom’s bottom sheet, though from this I learnt I won’t switch to the new architecture for a while, seems too risky and some really important modules aren’t ready.
A few things:
Here’s a list of dependencies that currently work for me
A quick note on the above. In order to work, @react-native-community/datetimepicker requires this in react-native-config.js
These don’t work
The root cause of the issue is the fact that Reanimated uses Fabric mode while the app still runs on Paper (old renderer):
As you can see, there’s no
"fabric":true
in the logs, meaning that your app still runs on the old architecture.Based on the value of
newArchEnabled
property, Reanimated correctly detects that Fabric is enabled and setsglobal._IS_FABRIC
totrue
which causes Reanimated to use Fabric implementation (e.g. to obtain ShadowNodeWrapper fromstateNode
field, which is undefined on Paper).The problem is that for some reason React Native doesn’t enable Fabric. This may be because your app is totally out-of-sync with React Native 0.69.5 template. In particular, the Android app still runs on Paper because the following method is missing:
Additionally, many of the third-party libraries that you use are not Fabric-compatible yet, for instance:
I’ve replaced
MainActivity.java
in your project with the one from RN 0.69.5 app template (see here), changed the Java package and app name. I also removed all other third-party libraries from package.json and other Android-specific files. The app now runs on Fabric and the issue is gone:Closing this issue as it’s not a bug in Reanimated, but a config issue on your side.
Hmm, I was but I could replicate this by rendering a plain reanimated view in an empty app too. See https://github.com/kyle-ssg/reanimated-reproduction/blob/main/mobile/app/App.tsx#L5
@prince-sugarfit nope, we don’t support this currently (and honestly we don’t plan to). edit: I’m assuming you mean turboModules = true & fabric = false
@khushal87 facing the same issue when playing around with @gorhom’s bottom-sheet
Same problem