내가 할 노력하고 무엇실패 소품 유형 : 잘못된 소품 값의 'keyboardType'- ReactNative
Warning: Failed prop type: Invalid prop 'keyboardType' of value "supplied to 'TextInput' expected one of ["default", "email-address", etc]
라는 경고를 보내고있어 선택한 dropdown
에 따라 keyboardType
을 변경됩니다.
잘 작동하지만이 오류가 계속 발생합니다. 내가 뭘 잘못하고 있는지 모르겠다. 나는 아직도 React와 ReactNative에 익숙하지 않습니다. 만약 누군가가 어떻게 작동 하는지를 설명 할 수 있으면 저에게 어떻게해야하는지 예제를 알려 주면 정말 감사하겠습니다.
여기
import ModalDropdown from 'react-native-modal-dropdown';
const types = ['Phone', 'Email Address', 'Name', 'Address'];
export default class SampleComponent extends Component{
constructor(props) {
super(props);
this.state = {
dataInput: '',
typeOfKeyboard: '',
};
}
// this is how I set the state to be inputed in my `keyboardType` props
typeSelectedOnSelect(id, value) {
if(value== 'Phone'){
this.setState({typeOfKeyboard: 'numeric'});
}else if(value== 'Email Address'){
this.setState({typeOfKeyboard: 'email-address'});
}else{
this.setState({typeOfKeyboard: 'default'});
}
}
render(){
<View style={{flexDirection: 'column', flex: 1, padding: 20}}>
<Text style={styles.contactTypeText}>Contact Type</Text>
<ModalDropdown
options={types}
onSelect={this.contactTypeOnSelect.bind(this)}
style={styles.dropdownContainer}
dropdownStyle={styles.dropdownStyle}
textStyle= {styles.dropdownText}
/>
<TextInput label="Type anything" keyboardType={this.state.typeOfKeyboard} onChangeText={(dataInput)=>this.setState({dataInput})} value={this.state.dataInput} />
</View>
이 도움을 주셔서 감사합니다 내 코드입니다!
내게 연락해 주셔서 감사합니다. 나는 더 이상 경고를받지 않습니다. – natsumiyu
그레이트 :). 다행스럽게 도울 수있어! – WilomGfx