Skip to content

refactor: migrated file LazyReactPackage to Kotlin #51085

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Xintre
Copy link

@Xintre Xintre commented May 2, 2025

Summary:

This PR migrates LazyReactPackage to Kotlin as requested in #50513.

Changelog:

[ANDROID] [CHANGED] - Migrate com.facebook.react.LazyReactPackage to Kotlin.

Test Plan:

  • replaced BaseReactPackage with LazyReactPackage in RNTesterApplication.kt
  • run RN tester on old architecture
  • executed legacy native module screen

@facebook-github-bot
Copy link
Contributor

Hi @Xintre!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@Xintre Xintre force-pushed the refactor/lazyreactpackage-kotlin-rewrite branch from 7c90936 to e22458b Compare May 2, 2025 22:52
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 2, 2025
@Xintre
Copy link
Author

Xintre commented May 2, 2025

@mateoguzmana the PR is ready for review!

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label May 2, 2025
Copy link
Collaborator

@mateoguzmana mateoguzmana left a comment

Choose a reason for hiding this comment

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

Thanks for migrating this! some small remarks.

@Xintre Xintre force-pushed the refactor/lazyreactpackage-kotlin-rewrite branch from fce91a0 to 468ecbb Compare May 13, 2025 08:06
@Xintre Xintre force-pushed the refactor/lazyreactpackage-kotlin-rewrite branch from 468ecbb to 84488e9 Compare May 13, 2025 08:44
@mateoguzmana mateoguzmana requested a review from cortinico May 15, 2025 09:41
Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Code looks generally good. Leaving some comments to make it better

val moduleSpec = nativeModules[position++]
val name = moduleSpec.name

return reactModuleInfoMap[name].let moduleHolder@{ reactModuleInfo ->
Copy link
Contributor

Choose a reason for hiding this comment

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

The moduleHolder@{ in the middle of the line is really weird to read.

Can you extract reactModuleInfoMap[name] to a separate variable to simplify this?

Comment on lines +48 to +50
override fun hasNext(): Boolean {
return position < nativeModules.size
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
override fun hasNext(): Boolean {
return position < nativeModules.size
}
override fun hasNext(): Boolean = position < nativeModules.size

return emptyList()
}

val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
val viewManagers: MutableList<ViewManager<*, *>> = mutableListOf()

}

val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
for (moduleSpec in viewManagerModuleSpecs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use buildList here instead

Comment on lines +113 to +115
public fun getViewManagers(reactContext: ReactApplicationContext): List<ModuleSpec> {
return emptyList()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public fun getViewManagers(reactContext: ReactApplicationContext): List<ModuleSpec> {
return emptyList()
}
public fun getViewManagers(reactContext: ReactApplicationContext): List<ModuleSpec> = emptyList()

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. 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.

4 participants