警告:函数作为React子元素无效. (本机) [英] Warning: Functions are not valid as a React child. (React-native )
本文介绍了警告:函数作为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屋!
查看全文