onCreate(null) ? #2917
Replies: 4 comments 2 replies
-
This looks very promising! Thanks a lot. I'll have hard time this upcoming week to give it any deeper thought, however I'll return back to you once I do! |
Beta Was this translation helpful? Give feedback.
-
Hello @bojanlozanovski77, thank you for sharing this excellent solution. It’s a great improvement over the current workaround 🚀 We've been working recently on handling configuration changes in React Native and the screens package, and a custom fragment factory seems to work for all different cases! For sure, it's a more precise way to handle the problem, and it won't affect the native side of the brownfield applications. Because of that, we would love to add this solution to our library and adjust the installation steps with it. I will prepare the PR. Thank you once again 😄 |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the idea @bojanlozanovski77 and @Skalakid for the implementation. I'll land #3089 which should close the discussion. |
Beta Was this translation helpful? Give feedback.
-
Hi, just wanted to let you know the Navigation router handles this a different way that means you don't have to edit the override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
if (screen) {
// normal processing
return coordinatorLayout;
}
return View(requireContext());
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, it seems like it'd become a standard for this onCreate(null) to be used as part of the main activity.
Given that this can be quite harmful for native apps that use RN only for a limited set of functionalities, what do you think about limiting the scope of what state is not preserved to only the RN related state not being preserved, and the state for the rest of the app to be preserved.
I've come up with something like this:
this way, the app state is preserved, while only the rn fragment state is not preserved.
custom factory:
self closing fragment:
in main activity (we set the factory before super.onCreate(...)):
additionally, this can also be added inside main activity oncreate:
Beta Was this translation helpful? Give feedback.
All reactions