Skip to content

fix: avoid NativeEventEmitter warnings when OtpVerify module shape is incomplete - #138

Open
tomerh2001 wants to merge 4 commits into
faizalshap:masterfrom
tomerh2001:codex/fix-native-event-emitter-contract
Open

fix: avoid NativeEventEmitter warnings when OtpVerify module shape is incomplete#138
tomerh2001 wants to merge 4 commits into
faizalshap:masterfrom
tomerh2001:codex/fix-native-event-emitter-contract

Conversation

@tomerh2001

@tomerh2001 tomerh2001 commented Feb 18, 2026

Copy link
Copy Markdown

Summary

  • normalize the module passed to NativeEventEmitter
  • use NativeModules.OtpVerify when available, otherwise fall back to an empty object
  • ensure addListener and removeListeners exist as no-op functions before creating NativeEventEmitter

Why

On newer React Native versions, NativeEventEmitter enforces both of these constraints:

  • the constructor argument must be non-null
  • when provided, the native module should expose addListener and removeListeners

Some setups of this package can violate one or both constraints, causing startup warnings and/or an invariant runtime error.

Validation

  • Verified in an RN 0.81 app using this package that startup warnings are removed.
  • Verified that the runtime invariant (new NativeEventEmitter() requires a non-null argument) is avoided with this normalization.

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.

1 participant