2035Builder
2035Builder5mo ago

TextDecoder not implemented Trpc react-native httpBatchStreamLink

Receiving the stream relies on the TextDecoder and TextDecoderStream APIs, which is not available in React Native. If you still want to enable streaming, you need to polyfill those. any refrence to this?
2 Replies
2035Builder
2035BuilderOP5mo ago
currently try
import { polyfillGlobal } from "react-native/Libraries/Utilities/PolyfillFunctions"

const applyGlobalPolyfills = () => {
const { TextEncoder, TextDecoder } = require("text-encoding")

polyfillGlobal("TextEncoder", () => TextEncoder)
polyfillGlobal("TextDecoder", () => TextDecoder)
}

export default applyGlobalPolyfills
import { polyfillGlobal } from "react-native/Libraries/Utilities/PolyfillFunctions"

const applyGlobalPolyfills = () => {
const { TextEncoder, TextDecoder } = require("text-encoding")

polyfillGlobal("TextEncoder", () => TextEncoder)
polyfillGlobal("TextDecoder", () => TextDecoder)
}

export default applyGlobalPolyfills
in my_layout.tsx
// calling this
applyGlobalPolyfills()
// calling this
applyGlobalPolyfills()
and ran expo run:ios but still getting same error
Gwendal
Gwendal2mo ago
Did you manage to manage to make it work eventually? I'm facing the same problem @2035Builder

Did you find this page helpful?