【问题标题】:Error while adding NavigationContainer in react native with typescript在使用打字稿反应本机时添加 NavigationContainer 时出错
【发布时间】:2020-09-30 16:56:24
【问题描述】:

当我在单独的文件上定义我的NavigationContainer 时,出现以下错误:

'NavigationContainer' refers to a value, but is being used as a type here. Did you mean 'typeof NavigationContainer'?

但是当我在App.tsx 中定义它时。

import React from 'react'
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();

function AppNavigator() {
  return (
    <NavigationContainer>
      <Stack.Screen
        name={Routes.SPLASH}
        component={SplashScreen}
        options={{
          headerShown: false,
        }}
      />
    </NavigationContainer>
  )
}

export default AppNavigator

我的问题是什么?

【问题讨论】:

    标签: typescript react-native react-navigation


    【解决方案1】:

    我将文件扩展名更改为 tsx 并且错误消失了。

    【讨论】:

      猜你喜欢
      • 2019-04-16
      • 2021-12-07
      • 2021-09-13
      • 2018-03-11
      • 1970-01-01
      • 2022-07-21
      • 1970-01-01
      • 2018-10-20
      • 1970-01-01
      相关资源
      最近更新 更多