I’m using react native 0.72.4
I’m getting this error: Reference Error: Property 'Text Encoder' doesn't exist
at multiple places in my app. I didn’t use it explicitly but my npm
packages like qr-code-svg
uses this package.
I don’t know what Text Encoder is or where it is used .. i don’t know why all of it occurs suddenly.
2
Answers
this worked for me using same react native 0.72.4
install text-encoding using
npm install --save text-encoding --legacy-peer-deps
then import it everywhere you have imported the qrcode like so
import 'text-encoding';
sample of how your code should look like when done with the install
hope this helps!
This solution worked for me (https://github.com/awesomejerry/react-native-qrcode-svg/issues/199#issuecomment-2283588262):
Navigate to node_module/qrcode/lib/core/byte-data.js file.
this.data = new TextEncoder().encode(data)
to
this.data = stringToUtf8Uint8Array(data)
.