We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
npm install react-native-smart-barcode --save react-native link
npm install react-native-smart-barcode --save
react-native link
#43 /node_modules/react-native-smart-barcode/android/src/main/java/com/reactnativecomponent/barcode/RCTCapturePackage.java // @Override public List<Class<? extends JavaScriptModule>> createJSModules() { return Collections.emptyList(); }
// @Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
#41 /node_modules/react-native-smart-barcode/Barcode.js npm install prop-types --save import React, {Component,} from 'react'; import PropTypes from 'prop-types';
npm install prop-types --save
import React, {Component,} from 'react';
import PropTypes from 'prop-types';
App.js
import React, { Component } from 'react'; import { View, StyleSheet, Alert, } from 'react-native';
import Barcode from 'react-native-smart-barcode';
export default class App extends Component { // 构造 constructor(props) { super(props); // 初始状态 this.state = { viewAppear: false, }; }
render() { return ( <View style={{ flex: 1, backgroundColor: 'black', }}> <Barcode style={{ flex: 1, }} ref={component => this._barCode = component} barCodeTypes={['org.iso.QRCode']} // add this prop onBarCodeRead={this._onBarCodeRead} /> ) }
componentDidMount() { let viewAppearCallBack = (event) => { this.setTimeout(() => { this.setState({ viewAppear: true, }) }, 255) } this._listeners = [ // this.props.navigator.navigationContext.addListener('didfocus', viewAppearCallBack) ] }
componentWillUnmount() { this._listeners && this._listeners.forEach(listener => listener.remove()); }
_onBarCodeRead = (e) => { console.log('e.nativeEvent.data.type = ${e.nativeEvent.data.type}, e.nativeEvent.data.code = ${e.nativeEvent.data.code}') this._stopScan() Alert.alert(e.nativeEvent.data.type, e.nativeEvent.data.code, [ { text: 'OK', onPress: () => this._startScan() }, ]) }
_startScan = (e) => { this._barCode.startScan() }
_stopScan = (e) => { this._barCode.stopScan() }
const styles = StyleSheet.create({ centerText: { flex: 1, fontSize: 18, padding: 32, color: '#777', }, textBold: { fontWeight: '500', color: '#000', }, buttonText: { fontSize: 21, color: 'rgb(0,122,255)', }, buttonTouchable: { padding: 16, }, });
work now
The text was updated successfully, but these errors were encountered:
No branches or pull requests
npm install react-native-smart-barcode --save
react-native link
#43
/node_modules/react-native-smart-barcode/android/src/main/java/com/reactnativecomponent/barcode/RCTCapturePackage.java
// @Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
#41
/node_modules/react-native-smart-barcode/Barcode.js
npm install prop-types --save
import React, {Component,} from 'react';
import PropTypes from 'prop-types';
App.js
import React, {
Component
} from 'react';
import {
View,
StyleSheet,
Alert,
} from 'react-native';
import Barcode from 'react-native-smart-barcode';
export default class App extends Component {
// 构造
constructor(props) {
super(props);
// 初始状态
this.state = {
viewAppear: false,
};
}
render() {
return (
<View style={{ flex: 1, backgroundColor: 'black', }}>
<Barcode style={{ flex: 1, }}
ref={component => this._barCode = component}
barCodeTypes={['org.iso.QRCode']} // add this prop
onBarCodeRead={this._onBarCodeRead} />
)
}
componentDidMount() {
let viewAppearCallBack = (event) => {
this.setTimeout(() => {
this.setState({
viewAppear: true,
})
}, 255)
}
this._listeners = [
// this.props.navigator.navigationContext.addListener('didfocus', viewAppearCallBack)
]
}
componentWillUnmount() {
this._listeners && this._listeners.forEach(listener => listener.remove());
}
_onBarCodeRead = (e) => {
console.log('e.nativeEvent.data.type = ${e.nativeEvent.data.type}, e.nativeEvent.data.code = ${e.nativeEvent.data.code}')
this._stopScan()
Alert.alert(e.nativeEvent.data.type, e.nativeEvent.data.code, [
{ text: 'OK', onPress: () => this._startScan() },
])
}
_startScan = (e) => {
this._barCode.startScan()
}
_stopScan = (e) => {
this._barCode.stopScan()
}
}
const styles = StyleSheet.create({
centerText: {
flex: 1,
fontSize: 18,
padding: 32,
color: '#777',
},
textBold: {
fontWeight: '500',
color: '#000',
},
buttonText: {
fontSize: 21,
color: 'rgb(0,122,255)',
},
buttonTouchable: {
padding: 16,
},
});
work now
The text was updated successfully, but these errors were encountered: