metafloor / bwip-js

Barcode Writer in Pure JavaScript
Other
2.13k stars 308 forks source link

Does this library support react-native? #338

Open QMY-ZQ opened 6 months ago

QMY-ZQ commented 6 months ago

I tried installing this library and the same problem occurred,Is there any solution?https://github.com/metafloor/bwip-js/issues/296

metafloor commented 6 months ago

This project should support react-native. You likely need to enable export maps support in your project - it is the modern multi-platform packaging solution.

QMY-ZQ commented 6 months ago

This project should support react-native. You likely need to enable export maps support in your project - it is the modern multi-platform packaging solution.

So, do you have any guidance?

ArturBuja commented 5 months ago

This project should support react-native. You likely need to enable export maps support in your project - it is the modern multi-platform packaging solution.

So, do you have any guidance?

https://www.npmjs.com/package/bwip-js Here, You have docs about RN. You'll need also a "react-zlib-js"; lib to make bwip works. Then U'll need use useState with useEffect for fetch code from bwipjs.toDataURL in async/await function then You can use Image from React Native to displey the code. This is big short but maybe it will tell you something

metafloor commented 5 months ago

Yesterday, new platform specific packages were released, one of which specifically targets react-native. Please try:

npm install @bwip-js/react-native

The import will then be structured as:

import bwipjs from "@bwip-js/react-native";
   // or to allow tree shaking by the bundler
import { qrcode, code128 } from "@bwip-js/react-native";

For the react-native install, the react-zlib-js library is listed as a dependency, so it should install automatically.

If you have any issues with using the platform-specific library, please let me know.