这是我的模板代码

import React, {Component} from 'react';
import {TextInput, View, Text,} from 'react-native';

const InputT = ({ label , inputvalue, ipOnChangeText, placeholder , secureTextEntry}) => {
    const {inputStyle, labelStyle, containerStyle} = styles;
    return(
        <View style = {containerStyle}>
            <Text style= {labelStyle} >{label}</Text>
            <TextInput
               secureTextEntry={secureTextEntry}
               autoCorrect={false}
               placeholder={placeholder}
               style= {inputStyle}
               value = {inputvalue}
               onChangeText = {ipOnChangeText}
            />
        </View>
    );
 }

const styles ={
    inputStyle:{
        color: '#333',
        fontSize: 16,
        lineHeight: 23,
        borderBottomColor: '#333',
        borderBottomWidth: 0.5,
        fontFamily: 'System',
    },
    labelStyle:{
        fontSize: 18,
        color: '#737373',
        paddingBottom: 10,
        fontFamily: 'System',
    },
    containerStyle:{
        flexDirection: 'column',
        marginTop: 10,
        marginBottom: 10
    }
}
export { InputT };

最佳答案

根据您的问题和评论,我认为您传递的是错误的属性。将您的登录表单更改为:

<InputT
  label= "Team Size"
  placeholder= "eg:10"
  value = {this.state.teamsize}
  ipOnChangeText = {teamsize => this.setState({ teamsize })}
/>


注意我如何将onChangeText更改为ipOnChangeText,这是您的InputT组件期望的属性的名称

关于reactjs - react native 自定义TextInput onchangeText不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45982610/

10-09 22:01