Skip to content

Add react-native-screens native configs in Android during new app initialization #2819

Description

@I-am-Pritam-20

Describe the Feature

Add react-native-screens native configs in Android as per described here : https://reactnavigation.org/docs/getting-started?framework=community-cli#installing-dependencies

Possible Implementations

  • The native codes can be added right when a new app is initialized.
  • For better performance with react-native-screens, as it is now a common part of all new @react-native-community/cli apps , so the native codes should already be there rather adding manually.

See the docs here : https://reactnavigation.org/docs/getting-started?framework=community-cli#installing-dependencies

Kotlin
import android.os.Bundle
import com.swmansion.rnscreens.fragment.restoration.RNScreensFragmentFactory

// ...

class MainActivity: ReactActivity() {
  // ...

  override fun onCreate(savedInstanceState: Bundle?) {
    supportFragmentManager.fragmentFactory = RNScreensFragmentFactory()
    super.onCreate(savedInstanceState)
  }

  // ...
}
Java
import android.os.Bundle;
import com.swmansion.rnscreens.fragment.restoration.RNScreensFragmentFactory;

// ...

public class MainActivity extends ReactActivity {
  // ...

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    getSupportFragmentManager().setFragmentFactory(new RNScreensFragmentFactory());
    super.onCreate(savedInstanceState);
  }

  // ...
}

Related Issues

Sometimes linking, unnecessary whitespaces, flickers may occur if the screen navigation animation does not render properly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions