【发布时间】:2021-07-07 02:39:18
【问题描述】:
在阅读了许多其他类似的问题后,我仍然无法导入我的自定义组件。
这里是主视图:
import React from 'react';
import {Image, StyleSheet, Text, View} from 'react-native';
import {LOGO} from '../../assets/logo.png';
import {testingInput} from './testingInput';
function tempScreen({navigation}) {
return (
<View style={
styles.container
}>
<View style={
styles.topContainer
}>
<Image styles={
styles.logo
}
scoure={LOGO}
resizeMode={'cover'}/>
<Text>
Here
</Text>
</View>
<View style={
styles.bottomContainer
}>
<testingInput/>
</View>
</View>
)
}
const styles = StyleSheet.create({
...
})
export default tempScreen;
这里是 tempButton 文件:
import React, {Component} from 'react';
import {TextInput, StyleSheet} from 'react-native';
const testingInput = (prop) => {
return (
<TextInput style={
styles.TextInput
}
placeholder="Email"
color="#ffffff"
placeholderTextColor="#ffffff"
autoCapitalize="none"></TextInput>
)
}
const styles = StyleSheet.create({
TextInput: {
height: 50,
flex: 1,
padding: 10,
marginLeft: 20
}
})
export default testingInput;
我收到了错误
“不变违规:组件
testingInput的视图配置getter 回调必须是一个函数(收到undefined)。确保以大写字母开头组件名称。”
任何帮助将不胜感激!
【问题讨论】:
-
从'./testingInput'导入TestingInput;试试这个,让组件在前,后总是大写。
标签: javascript reactjs react-native