Nosmai  Effects Nosmai  Moderation Nosmai Try-ons coming soon
Docs menu React Native
How-to guide

Manage the camera lifecycle in React Native

Keep one Fabric camera view mounted, coordinate pause and resume with navigation, switch lenses safely, and await native cleanup.

Platform React Native SDK version 1.0.0 Updated Aug 22, 2026 Time 6 min

Prerequisites

  • A working React Native quickstart
  • One mounted NosmaiCameraView
  • An Expo development build or native React Native application, not Expo Go

Pause and resume the camera

Use the public methods when navigation keeps the screen mounted but hides it:

await NosmaiCameraSdk.pauseCamera();
await NosmaiCameraSdk.resumeCamera();

Serialize focus events so a late resume cannot run after cleanup begins.

Switch the camera

Await the result and disable the control while switching:

const switched = await NosmaiCameraSdk.switchCamera();
if (!switched) return;

A false result means a rapid or concurrent request was safely skipped; operational failures reject with a typed SDK error.

Clean up before remounting

Unmount the camera view and await cleanup before creating a new owner:

await NosmaiCameraSdk.cleanup();

Remove SDK event subscriptions in the same route cleanup. Do not mount the next camera screen until the cleanup Promise settles.

Verify it worked

Switch lenses, background and foreground the app, then navigate away and back ten times. The OS camera indicator must turn off after cleanup, listeners must not duplicate, and one Fabric camera view must own the session.

Common errors

Error or symptomCauseFix
E_OPERATION_CANCELLEDCleanup superseded a queued camera operationIgnore the stale operation and wait for cleanup before remounting
Camera2 device errorAnother controller or old view still owns Android camera hardwareAwait cleanup and keep one mounted camera view
Events fire more than onceSubscriptions survived route teardownCall remove() on every SDK subscription during cleanup

Next steps

References

Was this page helpful?

Your response helps us prioritize documentation improvements.

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved