如何以本机运行简单程序但出现错误

时间:2019-09-12 10:51:23

标签: android react-native

error while app run开始学习react-native,但第一个程序未在设备中运行。 运行该程序的任何帮助。

  import React, {Fragment} from 'react';
  import { Alert,View } from 'react-native';  

   const App = () => {
   return (
    alert("Hello ")
    );
    }

  export default App;

在我的app.js文件上方

1 个答案:

答案 0 :(得分:2)

您的返回应包含一个react组件..alert不是一个组件,而是一个函数... 像这样使用来显示警报。...

import React, {Fragment} from 'react';
import { Alert,View } from 'react-native';  

 const App = () => {
 return (
  <View> 
    {Alert.alert("title ","message")}
  </View>
     );
   }

   export default App;
相关问题