Closed Mukesh0996 closed 2 years ago
Error that is cropping up TypeError: null is not an object (evaluating '_reactNativePrint.default.selectPrinter')]
My Code: import { StatusBar } from 'expo-status-bar'; import React, { Component } from 'react'; import { Button, Platform, StyleSheet, Text, TouchableHighlight, View } from 'react-native'; import RNPrint from 'react-native-print';
export default class extends Component { state = { currentSelectedPrinter : {} } //iOS only
selectPrinter = async () => { try { const currentSelectedPrinter = await RNPrint.selectPrinter({ x: 100, y: 100 }) console.log('printer is', selectedPrinter); this.setState({ currentSelectedPrinter: currentSelectedPrinter })
} catch (error) { console.log(error); }
} //only for iOS iOSOptions = () => {
return ( <View> <Button title="Silent Printing"/> </View> )
}
render () { return (
); } }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, t: { borderColor:'black', borderWidth: 2, padding: 5, borderRadius: 10 }, b: { padding: 1, borderWidth: 1, borderColor: 'blue', marginVertical: 1, borderRadius: 10, marginVertical:40 } });
Are you on a managed or bare workflow with Expo?
Error that is cropping up TypeError: null is not an object (evaluating '_reactNativePrint.default.selectPrinter')]
My Code: import { StatusBar } from 'expo-status-bar'; import React, { Component } from 'react'; import { Button, Platform, StyleSheet, Text, TouchableHighlight, View } from 'react-native'; import RNPrint from 'react-native-print';
export default class extends Component { state = { currentSelectedPrinter : {} } //iOS only
selectPrinter = async () => { try { const currentSelectedPrinter = await RNPrint.selectPrinter({ x: 100, y: 100 }) console.log('printer is', selectedPrinter); this.setState({ currentSelectedPrinter: currentSelectedPrinter })
} //only for iOS iOSOptions = () => {
}
render () { return (
); } }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, t: { borderColor:'black', borderWidth: 2, padding: 5, borderRadius: 10 }, b: { padding: 1, borderWidth: 1, borderColor: 'blue', marginVertical: 1, borderRadius: 10, marginVertical:40 } });