Home > front end >  react native TextInput : how do i make the text color (or style) not change when TextInput is disabl
react native TextInput : how do i make the text color (or style) not change when TextInput is disabl

Time:06-13

editable={false} enable={false}

editable={true} enable={true}

when i press the PencilButton, i want my texinput disabled. but when i press, text in textInput fade.

how to i get the original text?
but another way came to my mind. are you recommend this?

const [press,setPress] = useState(false) // when i press button: true
<PencilButton onPress={()=>{setPress(!press)}}
<TextArea press={press}/>

const TextArea = ({press}) => {
   if (press) {
      return <Text>value</Text>
   }
   else{
      return <TextInput/>
   }
}

this is when i press button, replace TextInput with Text.

CodePudding user response:

Use the editable prop to handle disable in react native TextInput. It won't change the text color.

<TextInput editable={press} />
  • Related