简体   繁体   English

JSX 表达式必须有一个父元素。 ts(2657)

[英]JSX expressions must have one parent element.ts(2657)

i am using React Native, i am freshman there , what is the problem here: mistake is there i am using React Native, i am freshman there , what is the problem here: mistake is there i am using React Native, i am freshman there , what is the problem here: mistake is there i am using React Native, i am freshman there , what is the problem here: mistake is there i am using React Native, i am freshman there , what is the problem here: mistake is there i am using React Native, i am freshman there , what is the problem here: mistake is there我正在使用 React Native,我是那里的新生,这里有什么问题:错误是我在使用 React Native,我是那里的新生,这里有什么问题:错误是我正在使用 React Native,我是那里的新生,这里有什么问题:错误是我使用 React Native,我是大一新生,这里有什么问题:错误是我使用 React Native,我是大一新生,这里有什么问题:有错误我正在使用 React Native,我是那里的大一新生,这里有什么问题:有错误

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

export default function App() {
  return (
  


    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>

    <View >
<Text>ffff</Text>
      </View>
 
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'red',
  },
});

You've to wrap up your content in a parent section or view like this:您必须将您的内容包含在父部分中或像这样查看:

import React from 'react';
import { StyleSheet, Text, View, StatusBar } from 'react-native';

export default function App() {
  return (
    <>
      <StatusBar barStyle="dark-content"/>
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
      </View>

      <View >
        <Text>ffff</Text>
      </View>
    </>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'red',
  },
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSX 表达式必须有一个父元素。 ts(2657) react native - JSX expressions must have one parent element.ts(2657) react native JSX 表达式必须有一个父元素。 ts(2657) 在 Return 语句中 - JSX expressions must have one parent element.ts(2657) In Return statement 不能用作 JSX 组件。 它的返回类型“void”不是有效的 JSX element.ts(2786) - cannot be used as a JSX component. Its return type 'void' is not a valid JSX element.ts(2786) 添加第二个时,React JSX 表达式必须有父元素错误<div> - React JSX expressions must have a parent element error when adding a second <div> 如何在不获取“ JSX表达式必须具有一个父元素的情况下”向我的添加模式组件中添加另一个模式。 错误” - How can I add another modal to my add modal component without getting “JSX expressions must have one parent element. error” JSX 中的大括号是什么意思? 如果它意味着 Javascript 表达式,那么为什么它会给出错误,“JSX 元素必须有一个父元素?” - What does curly braces inside JSX means? If it means Javascript expression, then why it is giving error, "JSX element must have one parent element?" JSX 元素类不支持属性,因为它没有“道具”属性。ts(2607) - JSX element class does not support attributes because it does not have a 'props' property.ts(2607) React - 如何解决:“vsX代码中的”JSX表达式必须具有父级和表达式“错误 - React - How to resolve: “JSX expression must have parent and expression expected” error in vs code JSX 元素类型“GoogleMapReact”没有任何构造或调用 signatures.ts(2604) - JSX element type 'GoogleMapReact' does not have any construct or call signatures.ts(2604) 打字稿类型定义:TS2604:JSX元素类型“某物”没有任何构造或调用签名 - Typescript type definition: TS2604: JSX element type 'something' does not have any construct or call signatures
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM