Git Product home page Git Product logo

Comments (2)

mrousavy avatar mrousavy commented on July 21, 2024 1
Error: Rendered fewer hooks than expected. This may be caused by an accidental early return statement

this is not VisionCamera's fault. You are using hooks wrong, I recommend you read about React hooks to make sure you understand how to properly use them.

Also, this is how to use it:

const front = useCameraDevice('front')
const back = useCameraDevice('back', { physicalDevices: [...] })

from react-native-vision-camera.

seereal-beomjin avatar seereal-beomjin commented on July 21, 2024

@mrousavy

const [isSelfee, setIsSelfee] = useState(false)

const front = useCameraDevice('front')
const back = useCameraDevice('back', { physicalDevices: ['ultra-wide-angle-camera', 'wide-angle-camera'] })

const backFormat = useCameraFormat(backDevice, [{photoAspectRatio: ios ? ratio : 9 / 16}, {photoResolution: 'max'}]);
const frontFormat = useCameraFormat(frontDevice, [{photoAspectRatio: ios ? ratio : 9 / 16}, {photoResolution: 'max'}]);
  
 const device = isSelfee ? frontDevice : backDevice;
 const format = isSelfee ? frontFormat : backFormat;
 
 
 return (
 <ReanimatedCamera
                          ref={cameraRef}
                          style={[styles.camera, {aspectRatio: 1 / ratio, width: '100%'}]}
                          device={device}
                          format={format}
                          isActive={true}
                          photo={isPhoto}
                          video={!isPhoto}
                          audio={!isPhoto}
                          animatedProps={animatedProps}
                          onTouchEnd={handleFocus}
                          zoom={device.neutralZoom}
                          exposure={exposure}
                          enableHighQualityPhotos
                        />
 )

In this code, when i change isSelfee false to true, an error has occur. but without physicalDevices: ['ultra-wide-angle-camera', 'wide-angle-camera'] }, it is work well

Rendered fewer h ooks than expected. This may be cause dby an accidental early return statement.

from react-native-vision-camera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.