Use the official FragmentManager extension to manage fragments: https://developer.android.com/guide/fragments/transactions
The goal of this example is to show you a way to prevent the fragment state loss and consequently avoid potential crashes of your app using kotlin extensions and android support library (version up to 26.0.0).
Check the Medium post for further information: