Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a react-native TextInput readonly

Tags:

react-native

I want to make a text input readonly in my RN application. I tried to set editable prop but it did not work properly. How can I achieve this?

<DetailInput
  inputStyle={styles.inputStyles} 
  height={120}
  width={width - 40}
  multiline={true}
  numberOfLines={6}
  underlineColorAndroid="transparent"
  maxLength={500}
  editable={!userRegistrationInProgress}
  onChangeText={value => this.statementChangedHandler(value)}
/>

const detailInput = props => {

    return (
      <TextInput
        {...props}
        style=
          {[
            props.inputStyle,
            { height: props.height, width: props.width},
            !props.valid && props.touched ? props.invalidInput : null
          ]}
      />
    );
}

export default detailInput;
like image 835
Shashika Avatar asked Aug 30 '18 06:08

Shashika


1 Answers

 <TextInput
    value = "Read Only"
    editable = {false}
 />

Set editable false to read only TextInput.

like image 149
Sathish Sundharam Avatar answered Jan 04 '23 00:01

Sathish Sundharam