无法在react-native中将类作为函数调用并使用expo运行]]

问题描述 投票:0回答:1

我正在使用EXPO在一个React-native项目中工作,我共享了链接,因此出错,请共享一个无错误的代码。我将在说明中分享我的代码

链接我的确切错误

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

我正在使用EXPO在一个React-native项目中工作,我共享了链接,因此出错,请共享一个无错误的代码。我将在描述链接中共享我的代码,以获取确切的错误https:// i ....

react-native expo
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.