Skip to content

Commit

Permalink
fix: avoid non-defined global error on web (#30)(by @AlanSl)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanSl authored Jun 23, 2022
1 parent 0fe2da0 commit d74fd20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utilities/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ type Print = (options: PrintOptions) => void;

let isLoggingEnabled = false;

// __DEV__ global is by default not defined in React Native Web builds
const isDev = Boolean(typeof __DEV__ !== 'undefined' && __DEV__)

const enableLogging = () => {
if (!__DEV__) {
if (!isDev) {
console.warn('[Portal] could not enable logging on production!');
return;
}
Expand All @@ -18,7 +21,7 @@ const enableLogging = () => {

let print: Print = () => {};

if (__DEV__) {
if (isDev) {
print = ({ component, method, params }) => {
if (!isLoggingEnabled) {
return;
Expand Down

0 comments on commit d74fd20

Please sign in to comment.