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

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

Closed
sofianegargouri opened this issue Jul 25, 2018 · 2 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@sofianegargouri
Copy link

Environment

Environment:
OS: macOS High Sierra 10.13.5
Node: 10.5.0
Yarn: 1.5.1
npm: Not Found
Watchman: 4.9.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: ~0.55.2 => 0.55.4

Description

Hi ! 👋
I initiated a new project with Expo, everything was working fine, but since I ejected it, I can't get rid of that error:

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

I have a little bit of experience with React Native but I can't put my finger on the problem here.

Reproducible Demo

Initiate a project with Expo
Eject it

/index.js:

import { AppRegistry } from 'react-native'
import App from './app'

AppRegistry.registerComponent('MyApp', () => App);

/app/index.js:

import React from 'react'
import { Text, View } from 'react-native'

export default () => (
  <View>
    <Text>Test</Text>
  </View>
)

And here is the error:

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

This error is located at:
    in RCTView (at View.js:60)
    in View (at AppContainer.js:102)
    in RCTView (at View.js:60)
    in View (at AppContainer.js:122)
    in AppContainer (at renderApplication.js:32)
throwOnInvalidElementType
    ReactNativeRenderer-dev.js:4706:4
createFiberFromElement
    ReactNativeRenderer-dev.js:4663:42
reconcileSingleElement
    ReactNativeRenderer-dev.js:8338:8
reconcileChildFibers
    ReactNativeRenderer-dev.js:8422:14
reconcileChildrenAtExpirationTime
    ReactNativeRenderer-dev.js:8622:8
reconcileChildren
    ReactNativeRenderer-dev.js:8603:6
updateHostComponent
    ReactNativeRenderer-dev.js:9001:22
beginWork
    ReactNativeRenderer-dev.js:9589:10
performUnitOfWork
    ReactNativeRenderer-dev.js:12924:25
workLoop
    ReactNativeRenderer-dev.js:12953:43
renderRoot
    ReactNativeRenderer-dev.js:12996:17
performWorkOnRoot
    ReactNativeRenderer-dev.js:13632:34
performWork
    ReactNativeRenderer-dev.js:13545:26
performSyncWork
    ReactNativeRenderer-dev.js:13506:16
requestWork
    ReactNativeRenderer-dev.js:13392:6
scheduleWorkImpl
    ReactNativeRenderer-dev.js:13259:24
scheduleWork
    ReactNativeRenderer-dev.js:13207:28
scheduleRootUpdate
    ReactNativeRenderer-dev.js:13930:17
_updateContainerAtExpirationTime
    ReactNativeRenderer-dev.js:13966:6
updateContainer
    ReactNativeRenderer-dev.js:13991:8
render
    ReactNativeRenderer-dev.js:14726:35
renderApplication
    renderApplication.js:49:21
run
    AppRegistry.js:102:10
runApplication
    AppRegistry.js:194:26
__callFunction
    MessageQueue.js:351:47
<unknown>
    MessageQueue.js:116:26
__guardSafe
    MessageQueue.js:314:6
callFunctionReturnFlushedQueue
    MessageQueue.js:115:17
@sofianegargouri
Copy link
Author

Found the issue:

import App from './app' is importing /app.json instead of the index of my /app folder.

app.json is containing the following, probably some rest from Expo:

{
  "expo": {
    "sdkVersion": "27.0.0"
  },
  "name": "MyApp",
  "displayName": "MyApp"
}

@oskaryil
Copy link

@sofianegargouri Thanks.. This had me going crazy.. Such a small unnoticable thing too.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 25, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants