Search code examples
react-nativereact-native-router-flux

react-native-router-flux onEnter to launch camera?


I'm using react-native-router-flux to navigate through my app. When the user logs in I have a TabBar with 3 buttons. When I click the middle button I want the user to take a picture and then in my 'cameraAdd' component I want to display the image and do other things.

My question is should I launch the camera using the onEnter fucntion in my Router, or is there a way to handle this in the cameraAdd component?

(I've console.logged constructor and componentWillMount in cameraAdd and this gets called on first render so not sure where to put it)

Thanks for any help.

<Scene key="camera" title="Camera" icon={TabIcon}>
        <Scene
          key="camera"
          component={cameraAdd}
          title="Camera"
          gestureEnabled={false}
          panHandlers={null}
          onEnter={() => console.log("onEnter!")}
        />
</Scene>

Solution

  • I cant say what happens when you do that via onEnter method, but i have used Camera in a custom component, which in your case is cameraAdd. for accessing and rendering camera view i used react-native-camera and i have never run into any issues with it as such. If you wish i can share an example of using Camera with help of react-native-camera.