Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

610
Views
I want to print a receipt with Bluetooth thermal printer in react native

Hello I want to print a receipt with Bluetooth thermal printer in react native. I have code as of now its working but giving a warning. with this code may i able to print a receipt please help to get rid of this warning also. here is my code. Warning possible Unhandled Promise Rejection (id: 0) TypeError:null is not an object (evaluating 'RNBLEPrinter.init')


    import React, { useState, useEffect } from "react";
    import {
      USBPrinter,
      NetPrinter,
      BLEPrinter,
    } from "react-native-thermal-receipt-printer";
    import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
    
    function Print() {
      const [printers, setPrinters] = useState([]);
      const [currentPrinter, setCurrentPrinter] = useState();
    
      useEffect(() => {
        BLEPrinter.init().then(() => {
          BLEPrinter.getDeviceList().then(setPrinters);
        });
      }, []);
    
      (_connectPrinter) => (printer) => {
        //connect printer
        BLEPrinter.connectPrinter(printer.inner_mac_address).then(
          setCurrentPrinter,
          (error) => console.warn(error)
        );
      };
    
      printTextTest = () => {
        currentPrinter && USBPrinter.printText("this is new print");
      };
    
      printBillTest = () => {
        currentPrinter && USBPrinter.printBill("this is for bill testing");
      };
      return (
        <View style={styles.container}>
          {printers.map((printer) => (
            <TouchableOpacity
              key={printer.inner_mac_address}
              onPress={() => _connectPrinter(printer)}
            >
              {`device_name: ${printer.device_name}, inner_mac_address: ${printer.inner_mac_address}`}
            </TouchableOpacity>
          ))}
          <TouchableOpacity onPress={printTextTest}>
            <Text>Print Text</Text>
          </TouchableOpacity>
          <TouchableOpacity onPress={printBillTest}>
            <Text>Print Bill Text</Text>
          </TouchableOpacity>
        </View>
      );
    }
    export default Print;
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
      },
    });

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

That looks like it may be coming from the react-native-thermal-receipt-printer library. Id look in the node module usually in the index.js file it will make that init call.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!