From ac9b87cd57029a0f0876aaec8d259d9befba9838 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 27 Dec 2023 08:47:02 -0800 Subject: [PATCH] Fix comment about adding packages in android template (#41856) Summary: I noticed this comment is still in Java in the Kotlin template. It also doesn't really work anymore since there is no packages variable. To fix it I completed the comment with all code needed for it to work in kotlin. I think an older version of the template used to be more like: ```kotlin val packages = PackageList(this).packages // packages.add(MyReactNativePackage()) return packages ``` But then it requires adding a lint suppress annotation since packages variable can be simplified. I think this is simpler even if it makes the comment a few more lines. ## Changelog: [GENERAL] [FIXED] - Fix comment about adding packages in android template Pull Request resolved: https://github.com/facebook/react-native/pull/41856 Test Plan: Tested that uncommenting that code works Reviewed By: cipolleschi Differential Revision: D51987483 Pulled By: cortinico fbshipit-source-id: d0135b5b536960017ccc7b25f92c75b3bd863cd9 --- .../src/main/java/com/helloworld/MainApplication.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt b/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt index 5c868b449d9087..a2f5caca408e10 100644 --- a/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt +++ b/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt @@ -15,11 +15,11 @@ class MainApplication : Application(), ReactApplication { override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) { - override fun getPackages(): List { - // Packages that cannot be autolinked yet can be added manually here, for example: - // packages.add(new MyReactNativePackage()); - return PackageList(this).packages - } + override fun getPackages(): List = + PackageList(this).packages.apply { + // Packages that cannot be autolinked yet can be added manually here, for example: + // add(MyReactNativePackage()) + } override fun getJSMainModuleName(): String = "index"