【问题标题】:React native - view config getter callback for component 'input' must be a function (received 'undefined')反应本机 - 组件“输入”的视图配置获取器回调必须是一个函数(收到“未定义”)
【发布时间】:2021-11-21 06:02:26
【问题描述】:

我正在尝试使用 但我收到此错误:

组件“输入”的视图配置 getter 回调必须是一个函数(收到“未定义”)。确保以大写字母开头的组件名称

代码如下:

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

const styles = StyleSheet.create({
    container: {
        flex: 1,
        marginTop: StatusBar.currentHeight,
        backgroundColor: "#F7F7F7FF",
        paddingTop: StatusBar.currentHeight,
        alignItems: "center",
        justifyContent: "center"
    },
    header: {
        backgroundColor: "pink",
        padding: 20,
    },
});

只有当我使用 时才会出现错误

【问题讨论】:

  • 你为什么不使用 "react-native" 或 "react-native-elements" 中的 ?
  • @Chilarai 我现在正在使用“react-native”????。我的 IDE 默认从“react-native-web”自动导入组件。

标签: javascript reactjs react-native expo


【解决方案1】:

问题来自于导入。

import {TextInput} from "react-native-web";

这个组件(来自 react-native-web)在 React Native 中不起作用

【讨论】:

    猜你喜欢
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 2021-10-05
    • 1970-01-01
    • 2020-08-14
    • 2020-11-11
    • 2021-03-10
    相关资源
    最近更新 更多