react-native-otp-verify
react-native-otp-verify copied to clipboard
Fix OTP listener registration race
Summary
- Register the JS OTP listener before starting SMS Retriever.
- Return the created subscription after SMS Retriever starts and remove it if startup fails.
- Add focused tests for listener ordering and cleanup.
Why
This prevents an OTP event from being emitted before the JS listener has been attached.
Fixes #141
Tests
- npm test -- --runInBand
- npx eslint src/index.tsx src/tests/index.test.tsx
- npm run typescript (fails: existing unused variables in example/src/App.tsx:16)
- npm run lint (fails: existing formatting/lint errors in dist/index.*, example/src/App.tsx, scripts/bootstrap.js)