Skip to content

Need better error message for "Invariant Violation: Objects are not valid as a React child ..." #18596

Closed
@RyanMitchellWilson

Description

@RyanMitchellWilson

I am getting a red screen from somewhere in my app and the only error I have just says "Invariant Violation: Objects are not valid as a React child ..." and the stack trace only has native components in it. Not a single thing printed in the stack trace is pointing to any of my code.

Environment

Environment:
OS: macOS High Sierra 10.13.3
Node: 7.5.0
Yarn: Not Found
npm: 4.4.1
Watchman: 4.7.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: =16.2.0 => 16.2.0
react-native: =0.53.3 => 0.53.3

Steps to Reproduce

All you need to reproduce this bug is to put an object inside your JSX. The problem here is that the stacktrace for this error does not point at the code that is actually causing the error, it is just a really long stacktrace with only React-Native components printed out.

Expected Behavior

If this error occurs it should have the exact line and file where the error occurred, that way people who run into this error can figure out where it is coming from and can fix it quickly and easily. Currently there is no possible way to figure out where this error came from except for digging through every file in your codebase and console logging every little thing that can be rendered, which if your codebase is a couple hundred files or larger that pretty much is not an option.

Actual Behavior

Currently you just get a stacktrace pointing at a bunch of native code, and nothing pointing at an actual file that you wrote, so it is pretty much impossible to figure out where this error is actually coming from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXIssues concerning how the developer experience can be improved.JavaScriptStaleThere 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