Rebase#2
Conversation
Load Android Gradle Plugin conditionally removed unnecessary buildToolsVersion specification extracted duplicated default versions extraction from the root project Gradle setup into a function
added annonation module
Improved Gradle setup
Fix null object crash.
Log.d internally uses the print method which needs not null value
fix command for adding package with yarn
Fix: IOS 'RNOtpVerify.getOtp'
Update README.md
Null pointer check applied
Removes new NativeEventeEmitter warning on Android
add support latest react-native v0.66
[ENH] remove duplicates from ReadMe
Updated Docs
added example added hook bumped react native version
fix: android gradlew version updated
Fix hardcoded OTP length
Fix crash due to null extras in OtpBroadcastReceiver.java
Add support for Android 14
fix: 0.73 build issue, and add exception handler
This helps decrease package size in npm since it is not required
fix: remove deprecated jcenter
chore(package.json): remove gradle and idea directories from files
feat: added sim available control and some reject callback for phoneHint
android - add support for AGP 8
There was a problem hiding this comment.
Pull request overview
This PR performs a major restructuring and modernization of the react-native-otp-verify library. It migrates from a basic TypeScript setup to a comprehensive library structure using react-native-builder-bob, adds proper build configurations, and includes an example application.
Key changes:
- Modernized TypeScript configuration with stricter compiler options
- Refactored source code with improved error handling and React hooks support
- Added comprehensive build tooling (bob builder, release-it, linting)
- Created example application demonstrating library usage
Reviewed changes
Copilot reviewed 57 out of 79 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Updated with modern TypeScript compiler options and stricter type checking |
| tsconfig.build.json | New build-specific TypeScript configuration |
| src/index.tsx | Complete rewrite with hooks support, better error handling, and iOS platform checks |
| src/tests/index.test.tsx | Placeholder test file (lacks implementation) |
| package.json | Major update with new build tools, scripts, and dependencies |
| scripts/bootstrap.js | Bootstrap script for development setup |
| react-native-otp-verify.podspec | iOS CocoaPods specification |
| example/* | Complete example application demonstrating library usage |
Files not reviewed (2)
- example/ios/OtpVerifyExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: Language not supported
- example/ios/OtpVerifyExample.xcworkspace/contents.xcworkspacedata: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1 @@ | |||
| it.todo('write a test'); | |||
There was a problem hiding this comment.
The test file only contains a placeholder todo test and lacks any actual test implementation. This means all the functionality added in src/index.tsx (getOtp, startOtpListener, useOtpVerify, getHash, requestHint, addListener, removeListener) has no test coverage.
| }; | ||
|
|
||
| if (os.type() === 'Windows_NT') { | ||
| options.shell = true |
There was a problem hiding this comment.
Missing semicolon at the end of the statement. This is inconsistent with the code style used in the rest of the file where semicolons are present.
| useEffect(() => { | ||
| if (Platform.OS === 'ios') { | ||
| console.warn('Not Supported on iOS'); | ||
| return; | ||
| } | ||
| getHash().then(setHash); | ||
| startOtpListener(handleMessage); | ||
| return () => { | ||
| removeListener(); | ||
| }; | ||
| }, []); |
There was a problem hiding this comment.
The useEffect hook is missing handleMessage in its dependency array. Since handleMessage is defined inside the component and references numberOfDigits, it should be included in the dependencies, or handleMessage should be wrapped with useCallback to prevent infinite re-renders. Without this, the effect may use stale closures or behave inconsistently.
| const [hint, setHint] = React.useState<string>(); | ||
|
|
||
| // using hook - you can use the startListener and stopListener to manually trigger listeners again. | ||
| const { hash, otp, timeoutError, stopListener, startListener } = useOtpVerify(); |
There was a problem hiding this comment.
Unused variable stopListener.
| const [hint, setHint] = React.useState<string>(); | ||
|
|
||
| // using hook - you can use the startListener and stopListener to manually trigger listeners again. | ||
| const { hash, otp, timeoutError, stopListener, startListener } = useOtpVerify(); |
There was a problem hiding this comment.
Unused variable startListener.
No description provided.