diff --git a/src/lib/is-browser.ts b/src/lib/is-browser.ts index fe69ce650..6252d810d 100644 --- a/src/lib/is-browser.ts +++ b/src/lib/is-browser.ts @@ -1,6 +1,11 @@ const isBrowser = (typeof window !== 'undefined' && typeof window.document !== 'undefined') || // eslint-disable-next-line no-restricted-globals - (typeof self !== 'undefined' && typeof self.postMessage === 'function') || // is web worker + (typeof self === 'object' && + // eslint-disable-next-line no-restricted-globals + self.constructor && + // eslint-disable-next-line no-restricted-globals + self.constructor.name === 'DedicatedWorkerGlobalScope') || // is web worker (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') // while navigator.product is deprecated + export default isBrowser