文本字符串必须在组件中呈现<Text>。 在应用程序中(由 withDevTools(App)创建)



我有一个本地react应用程序。我有这个简单的对象:

export const AnimalGroupScreen = () => (
<SafeAreaView style={styles.container}>
<View style={styles.search}>
<Searchbar />
</View>
<View style={styles.list}>
<AnimalGroupInfo />
</View>
</SafeAreaView>
);
import React from "react";
import { Text } from "react-native";
export const AnimalGroupInfo = () => <Text> Hello there</Text>;

和应用:

import { AnimalGroupScreen } from "./src/features/animalGroup/screens/animal-group-screen";
/* eslint-disable prettier/prettier */
import ExpoStatusBar from "expo-status-bar/build/ExpoStatusBar";
import React from "react";
export default function App() {
return (
<>
<AnimalGroupScreen />;
<ExpoStatusBar style="auto" />
</>
);
}

但是我仍然得到这个错误:

Error: Text strings must be rendered within a <Text> component.
This error is located at:
in App (created by withDevTools(App))
in withDevTools(App)
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)

当然我搜索了这个错误。但是我在Info组件中只有一个Text标签。

这似乎是正确的。那么如何解决这个错误呢?

这里有一个分号:

<AnimalGroupScreen />;

把它取下来,它应该可以工作。

remove;from<AnimalGroupScreen />;

最新更新