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

Created on 18 Oct 2018  路  5Comments  路  Source: callstack/react-native-paper


Current behaviour

As a result of wrapping my component with PaperProvider I've got the following error:

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

Check the render method of Portal.Host.

This error is located at:
in Portal.Host (at Provider.js:16)
in Provider (at MyCallsWrapper.js:7)
in MyCallsWrapper (at renderApplication.js:35)
in RCTView (at View.js:71)
in View (at AppContainer.js:102)
in RCTView (at View.js:71)
in View (at AppContainer.js:122)
in AppContainer (at renderApplication.js:34)

Code sample

MyCallsWrapper.js

import * as React from 'react';
import MyCallsScreen from "./MyCalls";
import {Provider as PaperProvider} from 'react-native-paper';

export default function MyCallsWrapper(props) {
    return (
        <PaperProvider>
            <MyCallsScreen userTags={props.userTags} phone_id={props.phone_id}/>
        </PaperProvider>
    )
}

MyCallsScreen.js

import React from "react";
import PropTypes from 'prop-types';

import {
    StyleSheet,
    View,
    InteractionManager
} from 'react-native';

export default class MyCallsScreen extends React.Component {
    // some logic
    render() {
        return (
            <View style={styles.container}>
                // some content
            </View>
        )
    }
}

inside index.js

AppRegistry.registerComponent('MyCalls', () => MyCallsWrapper);

Your Environment

| software | version
| --------------------- | -------
| ios or android | android
| react-native | 0.53.0
| react-native-paper | 2.1.3
| node | 10.8.0
| npm or yarn | 6.4.1

Most helpful comment

You forgot to import View component in MyCallsScreen.js

All 5 comments

Can you provide a demo on https://snack.expo.io?

You forgot to import View component in MyCallsScreen.js

That's not the case. I didn't forget to import View.
Just made a mistake providing the code for the issue.
The issue description was updated.

You need to provide a runnable demo. The code you provided looks ok, so it's not possible to debug without a demo.

The issue was resolved by updating react-native and react to version 0.55.4 and 16.3.1 respectively.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alikazemkhanloo picture alikazemkhanloo  路  4Comments

timothystewart6 picture timothystewart6  路  4Comments

zxccvvv picture zxccvvv  路  4Comments

kpervin picture kpervin  路  3Comments

ButuzGOL picture ButuzGOL  路  4Comments