React Native Camera

React Native Camera

  • Docs
  • Guides
  • API
  • Help
  • For Enterprise
  • GitHub

›Guides

Getting Started

  • Installation
  • Contributing

Guides

  • Expo Usage
  • Gradle Upgrade Guide
  • Migrating from RCTCamera to RNCamera
  • Migrating from version 1.x to 2.x
  • Migrating from version 2.x/3.x to 4.x
  • React Navigation
  • Recipes
  • RNCamera
  • Testing

API

  • Work in progress

Help

  • Q & A

Enterprise

  • React-Native-Camera for Enterprise
Edit

React Navigation

React-navigation does not unmount components when switching between tabs. So when you leave and return back to the screen with the camera component it will just be black view. A good solution is to use the useIsFocused hook, so you can render the camera view conditionally.

import { useIsFocused } from '@react-navigation/core';

export const Component = () => {
  const isFocused = useIsFocused();

  // ...

  if (hasCameraPermission === false) {
    return <Text>No access to camera</Text>;
  } else if (hasCameraPermission !== null && isFocused) {
    return <CameraView />;
  } else {
    return null;
  }
}
Last updated on 2/11/2021 by ThaJay
← Migrating from version 2.x/3.x to 4.xRecipes →
React Native Camera
Docs
Getting StartedGuidesAPI Reference
Community
User ShowcaseStack OverflowProject Chat
More
GitHubStars
Facebook Open Source
Copyright © 2021