Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comment about adding packages in android template #41856

Closed
wants to merge 6 commits into from

Conversation

janicduplessis
Copy link
Contributor

@janicduplessis janicduplessis commented Dec 8, 2023

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:

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

Test Plan:

Tested that uncommenting that code works

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Dec 8, 2023
@facebook-github-bot
Copy link
Contributor

@dmytrorykun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@analysis-bot
Copy link

analysis-bot commented Dec 8, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 16,513,050 -7,737
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 19,891,829 -3,668
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 1727ffa
Branch: main

@janicduplessis
Copy link
Contributor Author

@cortinico Good idea, I tested that the code works

@cortinico
Copy link
Contributor

@janicduplessis can we make it a bit nicer as:

        override fun getPackages(): List<ReactPackage> =
          PackageList(this).packages.apply {
            // Packages that cannot be autolinked yet can be added manually here, for example:
	        // add(MyReactNativePackage())
          }

@janicduplessis
Copy link
Contributor Author

@cortinico There you go!

…elloworld/MainApplication.kt

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
@facebook-github-bot
Copy link
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cortinico merged this pull request in ac9b87c.

huntie pushed a commit that referenced this pull request Dec 27, 2023
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: #41856

Test Plan: Tested that uncommenting that code works

Reviewed By: cipolleschi

Differential Revision: D51987483

Pulled By: cortinico

fbshipit-source-id: d0135b5b536960017ccc7b25f92c75b3bd863cd9
vbro1293 added a commit to vbro1293/sentry-docs that referenced this pull request Jan 2, 2024
I believe the getPackages Kotlin example is not valid Kotlin (it may have been ported from the react-native example comment - which now has a ticket to update the application of adding packages facebook/react-native#41856)
@@ -15,11 +15,11 @@ class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mix usages of 4 space tab and 2 space tab bothering me a lot 😞

Can I make PR? ( asking cause this doesn't resolve or implement anything )

Copy link
Contributor

@cortinico cortinico Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is autoformatted by ktfmt, so even if you send a PR that attempts to fix this, it will be reformatted back to how it is now

@janicduplessis janicduplessis deleted the patch-15 branch January 9, 2024 13:46
Othinn pushed a commit to Othinn/react-native that referenced this pull request Jan 9, 2024
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: facebook#41856

Test Plan: Tested that uncommenting that code works

Reviewed By: cipolleschi

Differential Revision: D51987483

Pulled By: cortinico

fbshipit-source-id: d0135b5b536960017ccc7b25f92c75b3bd863cd9
blakef pushed a commit to blakef/template that referenced this pull request Feb 28, 2024
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: facebook/react-native#41856

Test Plan: Tested that uncommenting that code works

Reviewed By: cipolleschi

Differential Revision: D51987483

Pulled By: cortinico

fbshipit-source-id: d0135b5b536960017ccc7b25f92c75b3bd863cd9

Original: facebook/react-native@ac9b87c
blakef pushed a commit to react-native-community/template that referenced this pull request Feb 29, 2024
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: facebook/react-native#41856

Test Plan: Tested that uncommenting that code works

Reviewed By: cipolleschi

Differential Revision: D51987483

Pulled By: cortinico

fbshipit-source-id: d0135b5b536960017ccc7b25f92c75b3bd863cd9

Original-Commit: facebook/react-native@ac9b87c
blakef pushed a commit to react-native-community/template that referenced this pull request Feb 29, 2024
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: facebook/react-native#41856

Test Plan: Tested that uncommenting that code works

Reviewed By: cipolleschi

Differential Revision: D51987483

Pulled By: cortinico

fbshipit-source-id: d0135b5b536960017ccc7b25f92c75b3bd863cd9

Original-Commit: facebook/react-native@ac9b87c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants