https://kotlinlang.org logo
#compose
Title
# compose
y

Yasser AKBBACH

11/18/2023, 3:26 PM
Hi, I noticed that, when using
ComposeView
in a fragment and when navigating back, the fragment doesn't get automatically destroyed! I needed to destroy it myself as:
Copy code
BackHandler {
    findNavController().navigateUp()
    onDestroyView()
    onDestroy()
}
PS: I'm using the composition strategy as:
Copy code
override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View = ComposeView(requireContext()).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
            setContent {}
        }
am I missing something?