Bug: TextDecoder doesn’t exist in React Native environment
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, react-native
- 领域
- mobile-dev
调研方向
首先阅读 node_modules/uint8array-tools/src/mjs/browser.js,并在报告中的 React Native 0.79.0 iOS 或 Android 环境中重现缺少 TextDecoder 的错误。检查如何使用 text-encoding 包而不影响浏览器或 Node.js 的行为;当该包在两个平台上都能正常工作且没有运行时错误时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
When using uint8array-tools in a React Native 0.79.0 project, the following error occurs at runtime:
Uncaught Error: Property 'TextDecoder' doesn't exist
browser.js:12:21
const DECODER = new TextDecoder();
^ Property 'TextDecoder' doesn't exist
Affected file:
node_modules/uint8array-tools/src/mjs/browser.js
Possible Cause
React Native does not provide TextEncoder or TextDecoder in the global environment.
As a result, libraries that depend on them (like this one) will throw errors when used outside of Node.js or browsers.
This can be mitigated by adding a small polyfill using the text-encoding
package.
Suggested Fix:
Add a conditional polyfill at the top of browser.js (or detect the React Native environment and import text-encoding only when needed).
import 'text-encoding'
Environment
React Native: 0.79.0
uint8array-tools: latest npm version
Platform: iOS (also occurs on Android)
- 主要语言
- JavaScript
- 星标
- 1
- 派生
- 3
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
bug 🐛
难度 2/5 1-3 小时 新手友好度 78/100
comunica/comunica#1960 · 1 条评论 ·
维护者通常 1 天内回复
-
Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 76/100
getsentry/sentry-javascript#26203 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
bytedance/flowgram.ai#1235 ·
维护者通常 1 天内回复