upgrade-support icon indicating copy to clipboard operation
upgrade-support copied to clipboard

LogBox Error at the beginning of the application

Open mateusmirandaalmeida opened this issue 5 years ago • 6 comments

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')

mateusmirandaalmeida avatar Apr 06 '20 01:04 mateusmirandaalmeida

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.

Tejpbit avatar Jun 05 '20 07:06 Tejpbit

I'm having the same issue when upgrading from react-native 0.61.4 to 0.63.4. I'm using xCode 12.2.

I tried the solution proposed by @Tejpbit but no success unfortunately.

Is there something else I can try?

Thanks

naquilini avatar Dec 15 '20 13:12 naquilini

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?

trizotti avatar Jan 11 '21 20:01 trizotti

??

jakubgrzelak avatar Jan 12 '21 11:01 jakubgrzelak

Also having the deprecated note showing...any solution?

selugbem avatar Jan 22 '21 01:01 selugbem

I ran into this error on React Native. For me, the issue was due to my code throwing an error before LogBox had a chance to start. Check your React Native debugger and see if there are any errors thrown before the error you're seeing in XCode.

AshlandWest avatar Nov 14 '22 18:11 AshlandWest