gpt4 book ai didi

javascript - React Native - 检查 `TabBarIcon` 的 render 方法

转载 作者:行者123 更新时间:2023-11-30 19:56:43 26 4
gpt4 key购买 nike

我在我的应用程序中呈现 createBottomTabNavigator 时遇到了这个问题。

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `TabBarIcon`.

我的代码

import React from "react";
import { createStackNavigator, createBottomTabNavigator, createAppContainer } from "react-navigation";
import { FontAwesome } from "react-native-vector-icons";

import SignUp from "./screens/SignUp";
import SignIn from "./screens/SignIn";
import Home from "./screens/Home";
import Profile from "./screens/Profile";

export const SignedOutNavigator = createStackNavigator({
SignUp: {
screen: SignUp,
navigationOptions: {
title: "Sign Up"
}
},
SignIn: {
screen: SignIn,
navigationOptions: {
title: "Sign In"
}
}
});

export const SignedInNavigator = createBottomTabNavigator({
Home: {
screen: Home,
navigationOptions: {
tabBarLabel: "Home",
tabBarIcon: ({ tintColor }) => (
<FontAwesome name="home" size={30} color={tintColor} />
)
}
},
Profile: {
screen: Profile,
navigationOptions: {
tabBarLabel: "Profile",
tabBarIcon: ({ tintColor }) => (
<FontAwesome name="user" size={30} color={tintColor} />
)
}
}
});

export const SignedOut = createAppContainer(SignedOutNavigator);
export const SignedIn = createAppContainer(SignedInNavigator);

引用:https://github.com/datomnurdin/auth-reactnative

最佳答案

导入的 FontAwesome 图标似乎有问题。该库似乎没有将 FontAwesome 的导出命名为默认值。

而是将其导入为

import FontAwesome from "react-native-vector-icons/FontAwesome";

关于javascript - React Native - 检查 `TabBarIcon` 的 render 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53910792/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com