Skip to content

Commit

Permalink
fix(react-native): error Cannot create URL for blob (#1840)
Browse files Browse the repository at this point in the history
* [Bug]: Error Cannot create URL for blob in React Native

* Change RN conditional logic

* Make conventional eslint styles
  • Loading branch information
MaximoLiberata committed Apr 10, 2024
1 parent c82a2be commit fc8fafb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/lib/BufferedDuplex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Duplex, Transform } from 'readable-stream'
import { Buffer } from 'buffer'
import { IClientOptions } from './client'

/**
Expand Down
6 changes: 4 additions & 2 deletions src/lib/get-timer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isBrowser, { isWebWorker } from './is-browser'
import isBrowser, { isWebWorker, isReactNativeBrowser } from './is-browser'
import { clearTimeout as clearT, setTimeout as setT } from 'worker-timers'
import type { TimerVariant } from './shared'

Expand Down Expand Up @@ -30,7 +30,9 @@ const getTimer = (variant: TimerVariant): Timer => {
}
case 'auto':
default: {
return isBrowser && !isWebWorker ? workerTimer : nativeTimer
return isBrowser && !isWebWorker && !isReactNativeBrowser
? workerTimer
: nativeTimer
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/is-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ const isBrowser =

export const isWebWorker = isWebWorkerEnv()

export const isReactNativeBrowser = isReactNativeEnv()

export default isBrowser
11 changes: 6 additions & 5 deletions src/lib/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ export function applyMixin(
}
}
}
export const nextTick = process
? process.nextTick
: (callback: () => void) => {
setTimeout(callback, 0)
}
export const nextTick =
typeof process?.nextTick === 'function'
? process.nextTick
: (callback: () => void) => {
setTimeout(callback, 0)
}

0 comments on commit fc8fafb

Please sign in to comment.