React native 找不到变量:Text

React native 找不到变量:Text,react-native,React Native,守则: // Import libraries for making a Component import React from 'react'; import ReactNative from 'react-native'; // Make a Component const Header = () => { return <Text>Albums!</Text>; }; // Make the Component available to other

守则:

// Import libraries for making a Component
import React from 'react';
import ReactNative from 'react-native';

// Make a Component
const Header = () => {
    return <Text>Albums!</Text>;
};

// Make the Component available to other parts of the App
export default Header;
//导入用于制作组件的库
从“React”导入React;
从“react native”导入ReactNative;
//制作组件
常量头=()=>{
返回相册!;
};
//使该组件可用于应用程序的其他部分
导出默认标题;

模拟器中带有bug的图像:

文本是组件,所以在使用它之前需要导入它。 但是,如果这不起作用,请尝试以下操作

return (
<Text>Hello</Text>
);
返回(
你好
);

您需要导入文本组件。确保在创建文本组件的文件中导出它。导出后,可以在头组件文件中写入以下内容:

    import Text from '/insert-path-to-Text-component/Text.js'

另外,由于在Header组件中返回的内容在一行中,因此不需要将其括在括号中。

从react native导入
文本
组件如何。您可以这样做,从“react native”导入{Text}

格式化代码。看起来您想要返回的内容周围缺少括号。也许可以尝试返回“相册”;“