Reactjs 如何运行react本机项目

Reactjs 如何运行react本机项目,reactjs,react-native,Reactjs,React Native,我写了这段代码,但它不工作,并且有错误 import React, {Component} from 'react'; import {Platform, StyleSheet, Text} from 'react-native'; type Props = {}; export default class App extends Component<Props> { render() { return ( <View style={styles.con

我写了这段代码,但它不工作,并且有错误

import React, {Component} from 'react';
import {Platform, StyleSheet, Text} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React Native!</Text>
        <Text style={styles.instructions}>To get started, edit App.js</Text>
        <Text style={styles.instructions}>{instructions}</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

import React,{Component}来自'React';
从“react native”导入{Platform,StyleSheet,Text};
类型Props={};
导出默认类应用程序扩展组件{
render(){
返回(
欢迎来到这里!
要开始,请编辑App.js
{指令}
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
为内容辩护:“中心”,
对齐项目:“居中”,
背景颜色:“#F5FCFF”,
},
欢迎:{
尺寸:20,
textAlign:'中心',
差额:10,
},
说明:{
textAlign:'中心',
颜色:'#333333',
marginBottom:5,
},
});
而且它不能像其他代码和我的应用程序崩溃那样正常工作
请帮我解决这个问题

在您的代码中,您忘记了在组件中导入视图 在第二行代码中 你应该这样写:

import {Platform, StyleSheet, Text, View} from 'react-native';
在本例中,您没有导入视图组件,因此请按如下方式导入视图组件

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

您需要从“react native”导入{View}&更改
说明
请尝试将错误添加到问题中。
import {Platform, StyleSheet, Text, View} from 'react-native';