question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Qr Scanner in TabNavigation

See original GitHub issue

Hello, how can i open the camera again after i click on the other navigationTab. It became black after i go back to QrScanner Tab. Im using react-navigation v2

untitled-1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

20reactions
alz10commented, Jul 17, 2018
import { withNavigationFocus } from "react-navigation";
import QRCodeScanner from "react-native-qrcode-scanner";
class QrCodeCamera extends Component {

      renderCamera() {
         const isFocused = this.props.navigation.isFocused();
         
         if (!isFocused) {
             return null;
         } else if (isFocused) {
             return (
                <QRCodeScanner />
             )
         }

      render() {
         return (
           <View style={{ flex: 1 }}>
              {this.renderCamera()}
           </View>
     }
}

export default withNavigationFocus(QrCodeCamera);
3reactions
danhnguyeencommented, Nov 3, 2018

I found this way. Hope it help


import React, { Component } from 'react';
import { View } from 'react-native';
import QRCodeScanner from 'react-native-qrcode-scanner';

class QRCode extends Component {
  state = {
    isRender: true
  }
  componentDidMount() {
    this.props.navigation.addListener('willFocus', (route) => {
      this.setState({ isRender: true })
    });
    this.props.navigation.addListener('willBlur', (route) => {
      this.setState({ isRender: false })
    });
  }
  render() {
    return (
      <View style={{flex: 1}}>
        { this.state.isRender &&
          <QRCodeScanner />
        }
      </View>
    );
  }
}
export default QRCode;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tab navigation - React Navigation
Run this code. Let's dissect this: tabBarIcon is a property on navigationOptions , so we know we can use it on our screen...
Read more >
Ricky Figures It Out: Simple React-Native TabNavigator using ...
Update: May-19: TabNavigator is depreciated from React Navigation and is now ... So we can style our text without having to write in-line...
Read more >
Top Tab Navigation in React Native Expo - YouTube
... create react native app, code step by step react native, react native design, deploy react native app, react native tutorial in Hindi, ......
Read more >
Combining Stack Navigation with Tab Navigation in React ...
Let's dive into the code then. #App.js //Your final app.js with stack navigator and tab navigatorimport * as React from 'react';
Read more >
Tab Navigation Between Screens Using React Navigation
We can use this navigation prop, to jump to any of the tabs. To move to the Story screen we use the code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found