Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Change State of Previous Scene #3020

Closed
StanislavSergeev opened this issue Apr 27, 2018 · 1 comment
Closed

How to Change State of Previous Scene #3020

StanislavSergeev opened this issue Apr 27, 2018 · 1 comment

Comments

@StanislavSergeev
Copy link

https://stackoverflow.com/questions/50063023/camera-always-working-in-react-native-router-flux-scene
This is my problem.

There are two scene in parent scene which have tab bar.
Initial Scene is simple view and second scene is QR Scanner and it uses RNCamera.

My problem is that Camera always working even though I am working at Initial Scene.

So if I can, I want to change state of second scene, so that stop camera.
Or is there any other way to stop camera?

@aksonov
Copy link
Owner

aksonov commented Jun 6, 2018

Answered.

Please use onEnter/onExit function together with Actions.refs.YOUR_CAMERA_SCENE to start/stop camera like this:

   <Router ...>
     <Scene tabs>
       <Scene />        // Scene1
       <Scene key='QR' onEnter={()=>Actions.refs.QR.startCamera()} onExit={()=>Actions.refs.QR.stopCamera()} />        // Scene2
     </Scene>
   </Router>

And your QR React Component should have startCamera and stopCamera methods.

@aksonov aksonov closed this as completed Jun 6, 2018
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

No branches or pull requests

2 participants