2035Builder
2035Builder4mo 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?
1 Reply
2035Builder
2035BuilderOP4mo 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