Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add element string to Invariant Exception: Element type is invalid message #17527

Closed
matthargett opened this issue Jan 10, 2018 · 1 comment
Closed
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@matthargett
Copy link
Contributor

Is this a bug report?

No. This is a missing usability feature that would have saved a fair amount of debugging time.

Have you read the Contributing Guidelines?

Yes.

Environment

React Native on iOS, Android, and Windows.

Environment:
OS: macOS Sierra 10.12.6
Node: 8.9.3
Yarn: 1.3.2
npm: 5.5.1
Watchman: 4.9.0
Xcode: Xcode 9.2
Android Studio: 3.0.1

Packages: (wanted => installed)
react-native: 0.49.5 => 0.49.5
react: 16.0.0-alpha.5 => 16.0.0-alpha.5

Target Platform: Windows, iOS, Android

Steps to Reproduce

  1. import a component from the wrong place (e.g. import ActivityIndicator from 'react-native-windows' instead of import ActivityIndicator from 'react-native'
  2. use the incorrectly imported symbol in a JSX tag: render() { return <ActivityIndicator />; }
  3. load the app and you get a stack trace similar to Invariant Violation: Element type is invalid: expected a string( for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in. #16332

Actual Behavior

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

Expected Behavior

In the actual case, it was a render function with a bunch of tags and it wasn't immediately clear which tag was causing the problem. It would be great if the string of the tag 'ActivityIndicator' could be captured and inserted into the exception message, like this:
Invariant Violation: Element type is invalid for "ActivityIndicator": expected a string (for built-in components) or a class/function (for composite components) but got: undefined

Reproducible Demo

See steps to reproduce.

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?

I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon. labels Feb 24, 2018
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 24, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Feb 24, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants