tr3v3r / react-native-esc-pos-printer

An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android
MIT License
164 stars 71 forks source link

Unhandled promise rejection [TypeError: privateMap.get is not a function. (In 'privateMap.get(receiver)', 'privateMap.get' is undefined)] #145

Closed powershek closed 4 months ago

powershek commented 5 months ago

I am trying the 4.0.0-beta.5 version, I can search the printer, once I create a new Printer as below, I got this error. Please help

new Printer({
  target: printer.target,
  deviceName: printer.model,
})

Error: Unhandled promise rejection [TypeError: privateMap.get is not a function. (In 'privateMap.get(receiver)', 'privateMap.get' is undefined)]

Environment : react-native: 0.66.0 react: 16.13.1 react-native-esc-pos-printer: 4.0.0-beta.5

tr3v3r commented 5 months ago

Hello @powershek,

Please provide a bit more information. Reproducible demo or at least code snippet.

What typescript version do you use?

powershek commented 5 months ago

I search the printer, result as below ,

{"bdAddress": "", 
"deviceName": "TM-T88VI", 
"deviceType": "TYPE_PRINTER", 
"ipAddress": "192.168.68.61", 
"macAddress": "F8:25:51:7C:10:3B", 
"target": "TCP:F8:25:51:7C:10:3B"
}

and I store the information to AsyncStorage and retrieve to use in the new Printer function

new Printer({ target: printer.target, deviceName: printer.deviceName, })

I still using js to make my project. any information need please let me know . Thank you very much

tr3v3r commented 5 months ago

@powershek please show me the screenshot with error, I wanna see stacktrace. Also please show me how you do import from the lib

powershek commented 5 months ago

beta5cap001

beta5cap002

powershek commented 5 months ago
async function SimplePrint() {
    let printerlist = await API.getAllPrinter();

    console.log("printerlist====================", printerlist)
    let advmodemainprinter = await API.getAdvModeMainPrinter();
    console.log("advmodemainprinter====================", advmodemainprinter)
    let targerPrinterObj = printerlist.filter((filteritem) => filteritem.TID == advmodemainprinter)[0]
    let targerPrinter = printerlist.filter((filteritem) => filteritem.TID == advmodemainprinter)[0].selectedprinter
    console.log("targerPrinter====================", targerPrinter)
    setPrinter(targerPrinterObj)
    console.log("targerPrinterObj====================", targerPrinterObj)

    console.log("targerPrinterObj dtl====================", targerPrinterObj.item.target, targerPrinterObj.item.modal)

      let printerInstance2 = new Printer({
        target: `{targerPrinterObj.item.target}`,
        deviceName: targerPrinterObj.item.modal,
      })

}
tr3v3r commented 4 months ago

For some reason, my message was not posted, but I've installed bare react native project (JS) version 0.66.0 and tried to reproduce your issue. Unfortunately not luck... Everything works as expected.

For now, I'll close the issue bit If you could provide a reproducible demo please feel free to reopen it

powershek commented 4 months ago

I found the issue happen in Printer.ts,

image

image

image

Problem on this line,

this.queue = new PQueue({ concurrency: 1 });

Could you please help

tr3v3r commented 4 months ago

@powershek hi,

As I said - no issue with the lib. I've checked on React Native (0.66 JS) bare project. Something wrong on your end.

Please try on a clean project. If you want you can create a reproducible demo or upload to github.

BTW you said previously that you project uses JS (not TypeScript), but on screenshots above you do logging in TS files. So what are using JS or TS?

powershek commented 4 months ago

@powershek hi,

As I said - no issue with the lib. I've checked on React Native (0.66 JS) bare project. Something wrong on your end.

Please try on a clean project. If you want you can create a reproducible demo or upload to github.

BTW you said previously that you project uses JS (not TypeScript), but on screenshots above you do logging in TS files. So what are using JS or TS?

I am using JS, I console log to the nearest line to check which line throw error. So i directly edit Printer.ts