neocotic / qrious

Pure JavaScript library for QR code generation using canvas
https://neocotic.com/qrious
Other
1.55k stars 215 forks source link

Not working with react-native? #54

Closed ychw closed 8 years ago

ychw commented 8 years ago

I tried line bellow in my react native project:

  const qr = new QRious({ value: mac });

and got following error:

2016-08-08 01:03:26.975 [error][tid:com.facebook.react.JavaScript] Can't find variable: document 2016-08-08 01:03:26.991 [fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: Can't find variable: document

neocotic commented 8 years ago

@ychw, I'm sorry but having never used (or even played with) React Native, I'm not sure that I can help you. Based on that error though it would appear that it does not run in a browser environment though, which would explain why document is missing.

Perhaps this is another reason why #53 would be useful, as we could have a separate module for other environments such as React Native (if possible). What I could do to allow for people to do this themselves in the meantime is allow them to specify their own ElementService implementation. Currently, QRious.use cannot be called twice, meaning the "element" service cannot be swapped out as this is called per bundle (i.e. Browser, Node.js).

Due to the nature of React Native, I believe a separate module would be best to support this, however, it could fall under this repo if we do move to multi-module.

Josema commented 5 years ago

Same problem. Why this library needs document or the browser/environment in order to work?