Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react native custom TextInput onchangeText Not working

This is My template code

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 };
like image 721
Ranjeet Avatar asked Oct 15 '25 18:10

Ranjeet


1 Answers

Based on your question and your comment I think you are passing the wrong property. Change your login form to:

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

Notice how I changed onChangeText for ipOnChangeText which is the name of the property your InputT component is expecting

like image 95
Emilio Rodriguez Avatar answered Oct 17 '25 11:10

Emilio Rodriguez