Skip to content

Commit 3f11a9e

Browse files
Tweak RN check
1 parent 6374f0e commit 3f11a9e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/snaps-utils/src/base64.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import type { VirtualFile } from './virtual-file';
1111
*/
1212
export async function encodeBase64(input: Uint8Array | VirtualFile | string) {
1313
const bytes = getBytes(input);
14+
const isReactNative =
15+
typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
1416
// In the browser, FileReader is much faster than bytesToBase64. This is not supported in React Native however.
15-
if ('FileReader' in globalThis && navigator?.product !== 'ReactNative') {
17+
if ('FileReader' in globalThis && !isReactNative) {
1618
return await new Promise((resolve, reject) => {
1719
const reader = Object.assign(new FileReader(), {
1820
onload: () =>

0 commit comments

Comments
 (0)