Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this library support react native? #36

Open
serhii-yalla opened this issue Oct 1, 2024 · 8 comments
Open

Does this library support react native? #36

serhii-yalla opened this issue Oct 1, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@serhii-yalla
Copy link

If so, what version is it support? For my case, I am on 0.75.3 version of react native.

@serhii-yalla
Copy link
Author

serhii-yalla commented Oct 1, 2024

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] 

@NielsLeenheer
Copy link
Owner

Apparently Hermes does not support structuredClone()... which is a bit surprising.
facebook/hermes#684

I'll see if I can include a polyfill in the next update.

@NielsLeenheer NielsLeenheer added the bug Something isn't working label Oct 1, 2024
@serhii-yalla
Copy link
Author

serhii-yalla commented Oct 2, 2024

@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 🫶

@NielsLeenheer
Copy link
Owner

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

@karaushu
Copy link

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.

@NielsLeenheer
Copy link
Owner

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.

@karaushu
Copy link

You can use Expo Snack, it's an easy way to test lib on real devices. Here is example

@ibrahimkundlik
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants