Bug: TextDecoder doesn’t exist in React Native environment

オープン
#13 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, react-native
領域
mobile-dev

調査の方向性

まず node_modules/uint8array-tools/src/mjs/browser.js を読み、報告されている TextDecoder の欠落エラーを、対象の React Native 0.79.0 iOS または Android 環境で再現します。ブラウザーや Node.js の動作に影響を与えずに text-encoding パッケージを使用する方法を確認します。両方のプラットフォームでランタイムエラーなしにパッケージが動作すれば完了です。

索引モデルが 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。