Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

606
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda