Skip to content

Console.dir error #29300

@pinpointpanda

Description

@pinpointpanda

Description

Using console.dir within emulators for both Android and iOS causes no problems, but it causes slightly tricky to debug errors in release builds, as it's obviously not supported on device. This has been reported before, but the issue was closed due to not following the template: #26281

If this is considered a bug, happy to raise a PR to just fallback to console.log which would probably be better behaviour.

React Native version:

System:
    OS: Windows 10 10.0.18362
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 3.05 GB / 15.92 GB
  Binaries:
    Node: 12.16.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.3
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: Version  3.6.0.0 AI-192.7142.36.36.6392135
  Languages:
    Java: 1.8.0_211
    Python: 3.8.2
  npmPackages:
    @react-native-community/cli: Not Found
    react: ~16.9.0 => 16.9.0
    react-native: ~0.61.5 => 0.61.5

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. In any react-native app, add a line to console.dir("test")
  2. This will work fine in emulators, but not on real Android and iOS devices: example error from Android
{ [TypeError: console.dir is not a function. (In 'console.dir(JSON.stringify(o))', 'console.dir' is undefined)] line: 1253, column: 2021, sourceURL: 'index.android.bundle' }

Expected Results

Describe what you expected to happen.

Ideally, this should just fallback to using console.log. What actually happens is an error is thrown.

Snack, code example, screenshot, or link to a repository:

As above, init a new react-native project, add a console.dir line and build for release and deploy to device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions