Skip to content

fix(android): replace BaseReactPackage with ReactPackage for RN 0.70-0.73 compatibility - #8

Merged
anngth merged 1 commit into
anngth:mainfrom
zoeyul:fix/react-native-0.70-compatibility
Nov 19, 2025
Merged

fix(android): replace BaseReactPackage with ReactPackage for RN 0.70-0.73 compatibility#8
anngth merged 1 commit into
anngth:mainfrom
zoeyul:fix/react-native-0.70-compatibility

Conversation

@zoeyul

@zoeyul zoeyul commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Description

Fixes build failure in React Native 0.70-0.73 caused by BaseReactPackage which doesn't exist in these versions.

Problem

BaseReactPackage was introduced in React Native 0.74. Using it causes build errors in RN 0.70-0.73:
Unresolved reference: BaseReactPackage

Solution

Replace BaseReactPackage with direct ReactPackage interface implementation, which exists in all React Native versions.

Changes

  • Changed ImageCodeScannerPackage from extending BaseReactPackage to implementing ReactPackage
  • Replaced getModule() and getReactModuleInfoProvider() with createNativeModules() and createViewManagers()
  • Maintains identical functionality with broader version compatibility

Summary by CodeRabbit

  • Refactor
    • Updated internal module initialization architecture to improve code maintainability and align with current framework standards. No changes to end-user functionality.

…0.73 compatibility

BaseReactPackage was introduced in React Native 0.74, causing
"Unresolved reference: BaseReactPackage" build error in RN 0.70-0.73.

Changed to ReactPackage interface which exists in all React Native versions.
@coderabbitai

coderabbitai Bot commented Nov 13, 2025

Copy link
Copy Markdown

Walkthrough

The ImageCodeScannerPackage is refactored from extending BaseReactPackage to directly implementing the ReactPackage interface. The module provisioning mechanism shifts from per-name module lookup via getModule to bulk provision via createNativeModules, with createViewManagers added to return an empty list.

Changes

Cohort / File(s) Summary
ReactPackage interface migration
android/src/main/java/com/imagecodescanner/ImageCodeScannerPackage.kt
Class redefined to implement ReactPackage instead of extending BaseReactPackage. Removed getModule and getReactModuleInfoProvider methods; added createNativeModules returning ImageCodeScannerModule and createViewManagers returning empty list. Imports updated to reflect ReactPackage-based implementation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file refactoring with consistent pattern change (BaseReactPackage → ReactPackage interface)
  • Clear, straightforward API migration with well-defined method replacements
  • No complex logic changes—primarily structural updates to module provisioning

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly describes the main change: replacing BaseReactPackage with ReactPackage to fix React Native 0.70-0.73 compatibility issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09068fa and 6897424.

📒 Files selected for processing (1)
  • android/src/main/java/com/imagecodescanner/ImageCodeScannerPackage.kt (1 hunks)
🔇 Additional comments (4)
android/src/main/java/com/imagecodescanner/ImageCodeScannerPackage.kt (4)

3-6: LGTM! Import changes align with ReactPackage interface.

The imports are correctly updated to support the ReactPackage implementation, including ViewManager for the createViewManagers() return type.


8-8: LGTM! ReactPackage interface ensures broad version compatibility.

Switching to ReactPackage correctly resolves the RN 0.70-0.73 build failures while maintaining compatibility with newer versions.


10-14: LGTM! Standard ReactPackage module provision.

The createNativeModules() implementation correctly returns the ImageCodeScannerModule, following the standard pattern for React Native packages.


16-20: LGTM! Correct implementation for package without view managers.

Returning an empty list is appropriate since this package only provides native modules, not custom view managers.

Verify that the refactored package maintains the same functionality across RN 0.70-0.74+. Consider adding or running integration tests with different React Native versions to confirm the fix resolves the build failures without introducing regressions.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@anngth
anngth merged commit 096b179 into anngth:main Nov 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants