Tracking Issue: Fabric support
See original GitHub issueIn the PR #1102, @TheSavior detailed the state-of-the-art for supporting Fabric (which had implications for long-term Animated support). We ended up discussing it in depth, so that thread should be considered prior reading to explain what aspects of the library are impacted, what changes are necessary, and why. In short:
- Fabric doesn’t have
findNodeHandle
anymore. - It has always been confusing, for many APIs, whether users need to obtain a ref to a class component instance, a ref to the host component, or a node handle to the host component.
- The
react-native-webview
library is particularly complex in this respect because<WebView>
renders a<View>
with a<NativeWebView>
child, which itself has scrolling behaviour (which incidentally will differ between macOS and iOS because the iOS WKWebView has a UIScrollView, yet the macOS WKWebView doesn’t contain a scrollView at all). There are valid reasons for a user or library (e.g. Animated/Reanimated) to require a ref to any of these various components. - Fabric’s approach is to ref-forward to the native component, then adorn it with public APIs from the class component that wraps it.
I began work on a branch to change the way refs are managed in this library to make this Animated support compatible with Fabric. However, I found that a rather large refactor was entailed, so I’ve decided to separate the PR from immediate Animated support and open the issue of Fabric support in general for proper discussion.
shirakaba/animated-support-fabric
is the branch. Note that the aspect of Animated support only constitutes three lines of code: the getScrollableNode
aspect. The rest is all related to Fabric. Note also that I’ve only touched the iOS implementation so far in this!
Note that this work is untested and may be missing some aspects; it’s merely my best understanding of how to implement the suggestions by @TheSavior. Hopefully it can illustrate the idea in mind.
I guess a starting point is to ask @TheSavior whether this implementation essentially looks correct for iOS?
Questions for the maintainers would be what they think about this ref-forwarding and adorning process and whether it means any breaking changes in the library and ecosystem around it.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top GitHub Comments
Hey @shirakaba @TheSavior , please let me know if there is any working version of react-native-webview that will support react native new architecture with fabric. I have to migrate my application to new architecture with fabric enabled so it’s a must for me before proceeding further. Thanks in advance.
I’m with @kartikmittal1996. I’ve just changed my whole application to Fabric, and react-native-webview would play a key role in this new version. I wish I had the knowledge to help you out, but if there is anything that is within my reach, feel free to ask.
I know @Titozzz has worked in this also. More details here: https://github.com/react-native-webview/react-native-webview/pull/2686