Skip to content

Decouple CodePush initializing lifecycle from ReactPackage initailizing #8

@CHOIMINSEOK

Description

@CHOIMINSEOK

It seems CodePush instance could be instantiated multiple times on new architecture if you initiate ReactPackage in ReactHostHelper Function.

// Not working  
  override val reactHost: ReactHost get() = getDefaultReactHost(
    context = this,
    packageList = PackageList(this).packages.apply {
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // add(MyReactNativePackage())
    },
    jsBundleFilePath = CodePush.getJSBundleFile(),
    useDevSupport = BuildConfig.DEBUG,
    isHermesEnabled = BuildConfig.IS_HERMES_ENABLED
  )

To prevent this, we guide to instantiate ReactPackage seperatly from ReactHost like this, but it's not intuitive, and different with default react-native configuration.

    val defaultPackageList by lazy { 
      PackageList(this).packages.apply {
        // Packages that cannot be autolinked yet can be added manually here, for example:
        // add(MyReactNativePackage())
      }
    }

  override val reactHost: ReactHost get() = getDefaultReactHost(
    context = this,
    packageList = defaultPackageList,
    jsBundleFilePath = CodePush.getJSBundleFile(),
    useDevSupport = BuildConfig.DEBUG,
    isHermesEnabled = BuildConfig.IS_HERMES_ENABLED
  )

Decouple CodePush initializing lifecycle from ReactPackage initailizing, so that RN configuration code doesn't affect on CodePush

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions