0

I want to open barcode scanner project on my device but I have a problem with this. I think, I import react-native-camera wrong way in my project. Can you help me about this problem?

enter image description here

  • npm: 6.4.1
  • react-native-cli: 2.0.1
  • react-native: 0.57.1

**

My package.json file :

**

{
  "name": "BarcodeScanner",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "^16.5.0",
    "react-native": "^0.57.1",
    "react-native-camera": "^0.6.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.45.6",
    "react-test-renderer": "16.5.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

**

My App.js file :

import React, {Component,PropTypes} from 'react';
import {View,Text} from 'react-native';
import {RNCamera} from "react-native-camera";

class App extends Component{

  constructor(props) {
    super(props);
    this.state = {
      qrcode: ""
    };
  }

  onBarCodeRead = e => {
    this.setState({ qrcode: e.data });
  };

  render() {
    return (
      <View style={styles.container}>
        <RNCamera
          barCodeTypes={[RNCamera.props.BarCodeType.qr]}
          flashMode={RNCamera.props.FlashMode.on}
          style={styles.preview}
          onBarCodeRead={this.onBarCodeRead}
          ref={cam => (this.props = cam)}
        >
          <Text
            style={{
              backgroundColor: "white"
            }}
          >
            {this.props.qrcode}
          </Text>
        </RNCamera>
      </View>
    );
  }
}

const styles = {
  container: {
    flex: 1,
    flexDirection: "row"
  },
  preview: {
    flex: 1,
    justifyContent: "flex-end",
    alignItems: "center"
  }
}

export default App;

**

Jose Vf
  • 1,493
  • 17
  • 26
Kaan Karamanoğlu
  • 189
  • 2
  • 5
  • 17

0 Answers0