react native expo QRcode GENERATOR

70gysomp  于 2023-05-18  发布在  React
关注(0)|答案(3)|浏览(128)

我想在React Native Expo中构建我的应用程序QRCODE Generator。
我使用QR码-模块react-native-qrcode版本0.2.7,我有这个error

xoshrz7s

xoshrz7s1#

react-native-qrcode不再维护。
可以使用react-native-qrcode-svg
https://www.npmjs.com/package/react-native-qrcode-svg

yarn add react-native-qrcode-svg

npm install --save react-native-qrcode-svg
u3r8eeie

u3r8eeie2#

import React, { Component } from 'react';
import { StyleSheet, View, TextInput, TouchableOpacity, Text,} from 'react-native';
import QRCode from 'react-native-qrcode';
class App extends Component {
constructor() {
super();
this.state = {
  inputValue: '',

  valueForQRCode: '',

    };
}

  getTextInputValue = () => {
this.setState({ valueForQRCode: this.state.inputValue });
};

 render() {
return (
  <View style={styles.MainContainer}>

    <TextInput
      style={styles.TextInputStyle}
      onChangeText={text => this.setState({ inputValue: text })}
      underlineColorAndroid="transparent"
      placeholder="Enter text to Generate QR Code"
    />
    <TouchableOpacity
      onPress={this.getTextInputValue}
      activeOpacity={0.7}
      style={styles.button}>
      <Text style={styles.TextStyle}> Generate QR Code </Text>
    </TouchableOpacity>
  </View>
);
}
}
     export default App;
icomxhvb

icomxhvb3#

你可以试试我开源的这个库:react-native-barcode-creator,它生成本机QR码,Code128,阿兹特克和PDF417条形码,适用于iOS和Android

相关问题