警告:函数作为 React 子级无效.(反应原生) [英] Warning: Functions are not valid as a React child. (React-native )

查看:36
本文介绍了警告:函数作为 React 子级无效.(反应原生)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:警告:函数作为 React 子级无效.

I am receiving the error: Warning: Functions are not valid as a React child.

我正在编写一个 React Native 应用程序.

I am writing a React Native application.

interface RegisterScreenProps {
  navigation: NavigationContainerRef;
}

const RegisterScreen: FunctionComponent<RegisterScreenProps> = ({
  navigation,
}: RegisterScreenProps) => {
  const { container, headerLogo, headerTitle, body } = styles;

  return (
    <SafeAreaView style={{ flex: 1 }}>
      <KeyboardAwareScrollView style={styles.container}>
        <View>
        <TextInput value={'afasfasdfdsfssddfsdfsffasf'} placeholder={'My Input'} />
        </View>
        
      </KeyboardAwareScrollView>
    </SafeAreaView>
  );
};

export default RegisterScreen;

我尝试了很多解决方案,但都没有成功.当我删除 KeyboardAwareScrollView 时,此代码可以正常工作.我需要用于 TextInput 的 KeyboardAwareScrollView.

I have tried many solutions but did not get success. When I remove KeyboardAwareScrollView this code works fine. i need KeyboardAwareScrollView for TextInput.

推荐答案

这是一个 react-native-keyboard-aware-scroll-view 的问题,在 这个提交 .

您需要将 package.json 中的 react-native-keyboard-aware-scroll-view 版本升级到 0.9.2

You need to upgrade your react-native-keyboard-aware-scroll-view version in package.json to 0.9.2

这篇关于警告:函数作为 React 子级无效.(反应原生)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆