【问题标题】:Cannot call a class as a function in react-native and run's using expo无法在 react-native 中将类作为函数调用并使用 expo 运行
【发布时间】:2020-03-12 08:31:59
【问题描述】:

我在一个使用 expo 的 react-native 项目中工作有一个错误我已经分享了链接,请分享一个无错误的代码。我将在描述中分享我的代码

我的确切错误的链接

App.js

 import React from 'react';
    import MovieList from './components/list';
    import  Detail from './components/detail';
    
    
    import { createAppContainer } from 'react-navigation';
    import { createStackNavigator } from 'react-navigation-stack';
    
    const AppNavigator = createStackNavigator({
      MovieList: {screen: MovieList},
      Detail: {screen: Detail},
    
    })
    
    const App = createAppContainer(AppNavigator);
    
    export default App();

detail.js

import React from 'react';
import { StyleSheet, View, Text} from 'react-native';
 
 export default class Detail extends React.Component {
 
  render() {
    return (
      <View>
        <Text>Details page here</Text>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  },
  item: {
    flex: 1,
    padding: 10,
    height: 50,
    backgroundColor: '#282C35'
  },
  itemText: {
color: '#fff',
fontSize: 24
  }
});

【问题讨论】:

    标签: react-native expo


    【解决方案1】:

    export default App(); 应改为 export default App;。错误告诉您App 不是函数,因此您需要删除括号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-25
      • 2020-02-11
      • 2019-07-14
      • 2018-04-24
      • 2018-09-07
      • 1970-01-01
      • 2020-05-06
      相关资源
      最近更新 更多