首页 > 解决方案 > TypeError:undefined 不是构造函数

问题描述

获取 TypeError:undefined 不是构造函数。

这是我的代码

import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import { StackNavigator } from 'react-navigation';
import LoginScreen from './Screens/LoginScreen';

export default function App() {
   return (
     <View style={styles.container}>
        <appStackNavigator />
     </View>
      );
  }

  const appStackNavigator = new StackNavigator({
    Login: { Screen: LoginScreen },

  });


   const styles = StyleSheet.create({
     container:
     {
       backgroundColor: '#AA00FF',
       flex: 1,
       alignItems: 'center',
       justifyContent: 'center',
     },
   });

这是我得到的错误:

TypeError:undefined is not a constructor(evaluating'new_reactNavigation.StackNavigator({Login:{Screen:_LoginScreen.LoginScreen}})')

请帮忙调试。

编辑:(帖子主要是代码,所以添加了一些支持问题的行)

标签: javascriptreact-native

解决方案


推荐阅读