metafloor / bwip-js

Barcode Writer in Pure JavaScript
Other
2.1k stars 301 forks source link

Does this library support react-native? #338

Open QMY-ZQ opened 4 months ago

QMY-ZQ commented 4 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 4 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 4 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 3 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 3 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.