question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LogBox Error at the beginning of the application

See original GitHub issue

Environment

System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
    Memory: 41.38 MB / 8.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.3.2 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 21, 22, 23, 24, 25, 26, 27, 28
      Build Tools: 19.1.0, 23.0.1, 27.0.2, 27.0.3, 28.0.3, 29.0.0
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.1 AI-173.4697961
    Xcode: 11.2.1/11B53 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.11.0 => 16.11.0 
    react-native: 0.62.1 => 0.62.1 
  npmGlobalPackages:
    react-native: 0.61.5

Upgrading version

0.62.1

Problem

LogBox must be enabled before AppContainer is required so that it can properly wrap the console methods.

Solution

As usual we separate the code inside the “src” folder. In the index.js file at the root of the project, we call it as follows:

require('react-native').unstable_enableLogBox()
...
import { App } from './src'

For me this generated the above error. To resolve, change the “import” to “require” Example:

require('react-native').unstable_enableLogBox()
...
const { App } = require('./src')

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:13
  • Comments:6

github_iconTop GitHub Comments

17reactions
Tejpbitcommented, Jun 5, 2020

That didn’t work for me.

What worked for me was creating a before.js file only containing the require('react-native').unstable_enableLogBox(); line. And then import './before'; at the very top of index.js

And I didn’t change the App import into a require.

2reactions
trizotticommented, Jan 11, 2021

Same problem here, the logs are saying that require(‘react-native’).unstable_enableLogBox() is now deprecated once it is included by default. Is there something else that worked for you guys?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Enable the new LogBox (RN) - react native
Error: LogBox must be enabled before AppContainer is required so that it can properly wrap the console methods. Please enable LogBox earlier in ......
Read more >
Issues with LogBox & Error Displaying - Expo SDK - Forums
If I haven't been working on the project for a few days, I don't even know what file to start with besides app.js...
Read more >
Intro to LogBox, React Native's new and improved debugging ...
LogBox addresses complaints that errors and warnings in React Native were too verbose, poorly formatted, and unactionable. The new solution is:
Read more >
Announcing React Native 0.63 with LogBox
Code Frames: Every error and warning now includes a code frame that shows the source code of the log right inside the app,...
Read more >
Logging in React Native: All you Need to know! - Biz4Solutions
Hermes improves an app's start-up time by ahead-of-time JS ... Whenever there's a Syntax error, a full-screen LogBox error appears.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found