Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

607
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda