无法在expo-native和run的expo中将类作为函数调用

时间:2019-11-16 10:23:43

标签: react-native expo

我正在使用expo在本机项目中工作,共享链接时出错,请共享无错误代码。我将在说明中分享我的代码

链接获取我的确切错误

https://i.stack.imgur.com/9I2jY.png

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
  }
});

1 个答案:

答案 0 :(得分:2)

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