activate and deactivate textInput

StackOverflow I’m trying to make a button to change the boolean value from true to false and vise versa in order to change editable value in textInput. This is how far I got till this momment:

  const [change, setChange] = useState(true);
  const [text, setText] = useState("");

  const textEdit = () => {
    change === true ? setChange(false) : setChange(true);

  };

for some reason after hitting below TouchableOpacity, it won’t change the state or there must be a problem in my code that prevent react from changing the state of “change” in the below text input

        <TextInput
          style={{ width: "100%", height: 100, backgroundColor: "gray" }}
          placeholder={"write something"}
          onChangeText={(text) => setText(text)}
          editable={change}
        >
          <Text>adderess</Text>
        </TextInput>


        <TouchableOpacity
          onPress={() => {
            textEdit;
          }}
        >
          <Text style={{ color: "blue" }}>Change</Text>
        </TouchableOpacity>

Answer

Because you don’t call function textEdit on press. Just update like this:

onPress={() => {
  textEdit();
}}

Or cleaner:

onPress={textEdit}