React.createElement:类型无效——需要一个字符串(对于内置组件)或一个 class/function(对于复合组件)

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components)

我在创建 for 循环时遇到了这个错误。

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s, undefined,  You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

导致错误的组件。

import React from "react";
import {TabWidgetNamespace} from "shared/namespaces/tab-widget.namespaces";
import {StyleSheet, Text, TouchableWithoutFeedbackComponent, View} from "react-native";

export class TabWidgetComponent extends React.Component<TabWidgetNamespace.TabWidgetPropsInterface, TabWidgetNamespace.TabWidgetStateInterface>{

style = StyleSheet.create({
    TabContainer: {
        overflow: 'hidden',
    },
    TabNavigation: {
        overflow: 'hidden'
    },
})

constructor(props: TabWidgetNamespace.TabWidgetPropsInterface) {
    super(props);
}

render(): React.ReactNode {

    const navigationItems = this.props.tabNavigation.map( (item, index) => (
            <TouchableWithoutFeedbackComponent key={index}>
                <Text>{item.label}</Text>
            </TouchableWithoutFeedbackComponent>
    ) );

    return(
        <View style={this.style.TabContainer}>
            <View style={this.style.TabNavigation}>
                {{ navigationItems }}
            </View>
        </View>
    );
}

}

我试过“export default class ComponentName”但我遇到了同样的错误。

发生错误是因为您试图在此处渲染对象 -

{{ navigationItems }}

你那里有多余的括号。应该是-

 { navigationItems }