-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get support fragment manager from ThemedReactContext #21356
Comments
It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the issue still exists. The ":rewind:Old Version" label will be removed automatically once you edit your original post with the results of running |
Upgraded react-native but the issue still persists |
@akdsouza I have the same issue. Have you found any workaround? |
Hi @aMarCruz , I went with just changing the MainActivity of the react generated android project to extend the ReactFragmentActivity instead of the default ReactActivity. Note however that after initially upgrading to RN 0.57, I later downgraded back to RN 0.55.4. This was based on a discussion I had at the end of this PR=> #20602 which I believe is based on this PR=> #19950 So far I haven't seen any problems but I haven't tested extensively for side effects. It's worth a try. |
@akdsouza , I think for public plugins supporting both MainActivity and FragmentActivity is the only path. In my case (a dialog lib) it is not so hard, although it introduces some duplication of code as in the React Native implementation. Thanks. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
Memory: 87.25 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.3 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.2, macOS 10.13, tvOS 11.2, watchOS 4.2
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 9.2/9C40b - /usr/bin/xcodebuild
npmPackages:
react: ^16.5.0 => 16.5.0
react-native: ^0.57.1 => 0.57.1
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Description
I'm writing a custom native android library that exposes a support fragment for display. I created a simple view manager on the android side of react in which I return a placeholder layout (just a frame layout inside a parent linear layout to replace with the fragment layout later) in
createViewInstance
and later intend to add the library fragment insidereceiveCommand
on user action from the react side. However in order to add the fragment to the container I cannot get the support fragment manager from theThemedReactContext
obj that I capture increateViewInstance
. DoingthemedReactContextObj.getCurrentActivity()
yields the deprecatedandroid.app.FragmentManager
. How do I getandroid.support.v4.app.FragmentManager
instead in my view manager? Any help is appreciated.Reproducible Demo
Here's the code I'm working with based off a few solutions on SO & blogs on getting native fragments to display. It works if I use a
android.app.Fragment
to display instead ofandroid.support.v4.app.Fragment
:As getFragmentManager() is deprecated, how do I get the support fragment manager from the ThemedReactContext ?
The text was updated successfully, but these errors were encountered: