user1790300
user1790300

Reputation: 1745

React-Native: expected a string or a class/function but got: object

For my react-native application, I am getting

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

app/index.js:

import React, { Component } from 'react';
import EStyleSheet from 'react-native-extended-stylesheet';
import { Provider } from 'react-redux';

import Navigator from './config/routes';
import { AlertProvider } from './redux/components/Alert';
import store from './config/stores';


EStyleSheet.build({
    $primaryBlue: '#4F6D7A',
    $primaryOrange: '#D57A66',
    $primaryGreen: '#00BD9D',
    $primaryPurple: '#9E768F',

    $white: '#FFFFFF',
    $lightGray: '#F0F0F0',
    $border: '#E2E2E2',
    $inputText: '#797979',
    $darkText: '#343434',
});

export default () => (
    <Provider store={store}>
        <AlertProvider>
            <Navigator onNavigationStateChange={null} />
        </AlertProvider>
    </Provider>
);

index.android.js and the index.ios.js:

import App from './app/index';
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';

AppRegistry.registerComponent("TestApp", App);

I tried to remove the Provider, AlertProvider, and Navigator tags and add a View tag just to see if I would still get an error, but I am getting the same error.

What am I doing wrong?

Upvotes: 0

Views: 471

Answers (1)

dhilt
dhilt

Reputation: 20844

Try to register your root component with

AppRegistry.registerComponent("TestApp", () => App);

Upvotes: 1

Related Questions