christopherdro / react-native-print

Print documents using React Native
MIT License
335 stars 142 forks source link

Issue while selecting printer. Is there a way to overcome this? #152

Closed Mukesh0996 closed 2 years ago

Mukesh0996 commented 3 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 (

Open up App.js to start working on your app!
christopherdro commented 2 years ago

Are you on a managed or bare workflow with Expo?