[英]React Native error - "Attempted import error: 'Item' is not exported from 'native-base'."
This is all the importing i did for my Code这是我为我的代码所做的所有导入
` `
import React from "react";
import {
TouchableOpacity,
TouchableWithoutFeedback,
StyleSheet,
Text,
SafeAreaView,
StatusBar,
KeyboardAvoidingView,
Keyboard,
View,
Alert,
Modal,
FlatList,
Animated,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { Container, Item, Input } from "native-base";
//AWS Amplify modular import
import data from "./countriesData.js";
//Load the app logo
const logo = require("./images/Triton Logo border.png");
` `
I'm not copying the full rendering, but i am going to paste here the Item part i'm getting an error from我不会复制完整的渲染图,但我会在此处粘贴我从中收到错误的 Item 部分
` `
<Item style={styles.itemStyle}>
<Ionicons name="ios-person" style={styles.iconStyle} />
<Input
style={styles.input}
placeholder="Username"
placeholderTextColor="#adb4bc"
keyboardType={"email-address"}
returnKeyType="next"
autoCapitalize="none"
autoCorrect={false}
onSubmitEditing={(event) => {
this.refs.SecondInput._root.focus();
}}
onChangeText={(value) =>
this.onChangeText("username", value)
}
onFocus={() => this.fadeOut()}
onEndEditing={() => this.fadeIn()}
/>
</Item>
` `
For some reason i get an error saying:出于某种原因,我收到一条错误消息:
Attempted import error: 'Item' is not exported from 'native-base'.
192 | <View style={styles.container}>
193 | {/* username section */}
> 194 | <Item style={styles.itemStyle}>
| ^
195 | <Ionicons name="ios-person" style={styles.iconStyle} />
196 | <Input
197 | style={styles.input}
I'm just not getting what the problem is.我只是不明白问题是什么。 I've tried to install native-base on NPM but it's not working Maybe it's something i have deep in the code, i need help please, Anybody with ReactNative experience can help me on this problem.
我已经尝试在 NPM 上安装 native-base 但它不起作用也许这是我深入了解代码的原因,我需要帮助,任何有 ReactNative 经验的人都可以帮助我解决这个问题。 i would appreciate it a lot.
我将不胜感激。
You are getting this error because you are trying to import <Item>
that is not present in NativeBase v3 .您收到此错误是因为您正在尝试导入NativeBase v3中不存在的
<Item>
。 either downgrade NativeBase to v2
or将NativeBase降级到
v2
或
keep NativeBase v3 and replace Form with FormControl
as mentioned in the docs .保留 NativeBase v3 并将 Form 替换为文档中提到的
FormControl
。
In your case like this:在你的情况下是这样的:
<FormControl>
<Stack style={styles.itemStyle}>
<Ionicons name="ios-person" style={styles.iconStyle} />
<Input
style={styles.input}
placeholder="Username"
placeholderTextColor="#adb4bc"
keyboardType={"email-address"}
returnKeyType="next"
autoCapitalize="none"
autoCorrect={false}
onSubmitEditing={(event) => {
this.refs.SecondInput._root.focus();
}}
onChangeText={(value) =>
this.onChangeText("username", value)
}
onFocus={() => this.fadeOut()}
onEndEditing={() => this.fadeIn()}
/>
</Stack>
</FormControl>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.