Skip to content

Commit

Permalink
Use vals inside ReactApplication (#38088)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #38088

For better Kotlin interop we should be using `val` in this interface rather than just `fun`.
This is not a breaking change as Java users can still use `getReactNativeHost()` as before.

Changelog:
[Internal] [Changed] -  Use vals inside ReactApplication

Reviewed By: javache

Differential Revision: D47053030

fbshipit-source-id: 4a7fbc71a76be54e1cf7daef499b9bc3e8fc615a
  • Loading branch information
cortinico authored and facebook-github-bot committed Jun 30, 2023
1 parent 3a912a3 commit c3f672c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import com.facebook.react.interfaces.ReactHostInterface
/** Interface that represents an instance of a React Native application */
interface ReactApplication {
/** Get the default [ReactNativeHost] for this app. */
fun getReactNativeHost(): ReactNativeHost
val reactNativeHost: ReactNativeHost

/**
* Get the default [ReactHostInterface] for this app. This method will be used by the new
* architecture of react native
*/
fun getReactHostInterface(): ReactHostInterface? {
return null
}
val reactHostInterface: ReactHostInterface?
get() = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.facebook.soloader.SoLoader

class MainApplication : Application(), ReactApplication {

private val reactNativeHost: ReactNativeHost =
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
// Packages that cannot be autolinked yet can be added manually here, for example:
Expand All @@ -27,8 +27,6 @@ class MainApplication : Application(), ReactApplication {
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}

override fun getReactNativeHost(): ReactNativeHost = reactNativeHost

override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
Expand Down

0 comments on commit c3f672c

Please sign in to comment.