Closed syuanlj closed 3 months ago
I am facing the same issue too
same error
@syuanlj same here, but can you provide more info regarding which version you are using. also the output of npx react-native info
can help
This solution worked for me:
First, install the text-encoding
package by running the following command:
npm install --save text-encoding
Then, import it into the file where you are using the QRCode:
import 'text-encoding';
this is influenced by: https://github.com/facebook/hermes/issues/948#issuecomment-1484240071
created a pull request.
who can't wait for merge just change this in package.json
"react-native-qrcode-svg": "https://github.com/12ya/react-native-qrcode-svg"
This solution worked for me:
- First, install the
text-encoding
package by running the following command:npm install --save text-encoding
- Then, import it into the file where you are using the QRCode:
import 'text-encoding';
this is influenced by: facebook/hermes#948 (comment)
This solution worked for me:
Navigate to _nodemodule/qrcode/lib/core/byte-data.js file.
Please update below line :
this.data = new TextEncoder().encode(data)
to this.data = stringToUtf8Uint8Array(data)
.
Add this function in same file :
function stringToUtf8Uint8Array(str) {
const utf8 = encodeURIComponent(str)
.replace(/%([0-9A-F]{2})/g, (_, p1) => String.fromCharCode('utf-8'));
const arr = new Uint8Array(utf8.length);
for (let i = 0; i < utf8.length; i++) {
arr[i] = utf8.charCodeAt(i);
}
return arr;
}