我希望在React Native Expo中构建我的应用程序QRCODE GENERATOR。
我使用QR码模块react-native-qrcode版本0.2.7,但是出现了error。
我希望在React Native Expo中构建我的应用程序QRCODE GENERATOR。
我使用QR码模块react-native-qrcode版本0.2.7,但是出现了error。
react-native-qrcode
已不再维护。
您可以使用react-native-qrcode-svg
包。
yarn add react-native-qrcode-svg
或者
npm install --save react-native-qrcode-svg
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;