Does this library support react native?
If so, what version is it support? For my case, I am on 0.75.3 version of react native.
BTW. Tried latest 3.0.1 version. Built successful, but not working. Code that calling class construct display that.
(NOBRIDGE) ERROR [ReferenceError: Property 'structuredClone' doesn't exist]
Apparently Hermes does not support structuredClone()... which is a bit surprising.
https://github.com/facebook/hermes/issues/684
I'll see if I can include a polyfill in the next update.
@NielsLeenheer May I ask you to add some variants to print images on web and mobile side? Cause I can't find a way to get image data to pass to your image method of escpos builder 🫶
In the examples directory there are a lot of libraries that can be used with ReceiptPrinterEncoder, and some are plain JavaScript, so I am sure some of them support React Native as well. But I am not familiar with how React Native works, so I can't give you examples of how to use it.
https://github.com/NielsLeenheer/ReceiptPrinterEncoder/tree/main/examples/images
Got something similar: Cannot find 'ImageData' in browser.js (3:18).
Expo 51, React Native, 0.74.5, hermes engine. It's try to import an canvas with will not work in RN.
That main be an issue with the bundler your project is using. ImageData is import from the @canvas/image-data package. That package has two code paths: one for the browser and one for Node. Apparently the bundler picks the path for the browser. And then it expects the browser native ImageData to be there. Which it isn't.
Not sure if that is helpful or not. Maybe the @canvas/image-data package itself is not React Native compatible. If that is the issue then perhaps we can work around it in a future version.
Ideally, for better React Native support I would need a sample project somewhere on Github which I could clone and play around with, without having to learn React Native from the ground up.
You can use Expo Snack, it's an easy way to test lib on real devices. Here is example
@serhii-yalla @karaushu Were you guys able to figure out if ReceiptPrinterEncoder can work correctly with react-native or not ?
I am also getting the same error around structuredClone as mentioned by @serhii-yalla in above comment.
I'm using 2.1.1 as of now because this does not run on RN for me, hopefully ImageData can be replaced/substituted for React Native developers
I have created a PR on @canvas/image-path in order to fix the resolution problem on react-native https://github.com/node-gfx/image-data/pull/4
I've released ImageData 🚢 1.1.0 / 2025-10-14 which points to the correct file for React Native 🚀
It works for me with one workaround: I had to redeclare structuredClone, seems like the constructor required it. Thank you!