admin管理员组文章数量:1391960
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.
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.
Share Improve this question asked Aug 8, 2024 at 12:04 VIGNESH KUMARANVIGNESH KUMARAN 632 silver badges7 bronze badges 2- This question is similar to: Expo React Native Can't find variable: TextDecoder. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – user18309290 Commented Aug 8, 2024 at 13:48
-
Upgrading React Native to a version that includes TextEncoder will fix this. Otherwise, what's happening is you likely have something that's trying to access TextEncoder like it's in a browser. You can try exlcuding
qr-code-svg
from loading using Metro's blocklist if you can't remove it. – Slbox Commented Feb 12 at 3:35
3 Answers
Reset to default 5this 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
import QRCode from 'react-native-qrcode-svg';
import 'text-encoding';
hope this helps!
They have fixed this issue with version 6.3.2
Update to this version and everything should work fine.
Ref:
- https://github./grgia/react-native-qrcode-svg/issues/199
- https://github./grgia/react-native-qrcode-svg/pull/200
Package text-encoding is no longer maintained. You should install a polyfill.
npm install text-encoding-polyfill
And include it at the top of your project.
// index.js
import 'text-encoding-polyfill'
本文标签: javascriptReferenceError Property 39TextEncoder39 doesn39t existStack Overflow
版权声明:本文标题:javascript - ReferenceError: Property 'TextEncoder' doesn't exist - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744591509a2614518.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论