简体   繁体   English

React Native 错误 - “尝试导入错误:'Item' 未从 'native-base' 导出。”

[英]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 orNativeBase降级到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.

相关问题 尝试导入错误:“ DeviceEventEmitter”未从“ react-native”导出 - Attempted import error: 'DeviceEventEmitter' is not exported from 'react-native' 尝试导入错误:“shouldUseActivityState”未从“react-native-screens”导出 - Attempted import error: 'shouldUseActivityState' is not exported from 'react-native-screens' 尝试导入错误:当编译react-native到react-native-web时,不会从&#39;./apiFetcher&#39;导出&#39;ApiGet&#39; - Attempted import error: 'ApiGet' is not exported from './apiFetcher' when compile react-native to react-native-web 尝试导入错误:“createElement”未从“react-native”导出。 @react-native-picker/picker/js/Picker.web.js - Attempted import error: 'createElement' is not exported from 'react-native'. @react-native-picker/picker/js/Picker.web.js 导入反应导航和本机库时出错 - Error while importing react-navigation & native-base 加载字体本机基础错误 - Loading font native-base error 尝试导入错误:'未从 - Attempted import error:' is not exported from 尝试导入错误:“getMoviesList”未从“./actions”导出; 反应错误 redux - Attempted import error: 'getMoviesList' is not exported from './actions'; error in react redux 反应错误“尝试导入错误:'TodoItem'未从'./Todoitem'导出。” - error in react " Attempted import error: 'TodoItem' is not exported from './Todoitem'. " React Native Project-使用Native-Base DatePicker引发不变违规错误 - React Native Project - Using Native-Base DatePicker throws an Invariant Violation error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM