D
D
Dev-20202021-12-11 18:24:50
React Native
Dev-2020, 2021-12-11 18:24:50

React Native How to change true/false on click?

There is such a code, when clicked, the state changes to "false" once only when clicked. How to make boolean value change permanently to false/true when pressing ?

const [passVissible, setPassVissible] = useState(true);

    <TouchableOpacity onPress={() => setPassVissible(false) }>
        <Text>{passVissible}</Text>
    </TouchableOpacity>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksim Tynkovich, 2021-12-12
@wildfires

TouchableOpacity onPress={() => {setPassVissible(prevpassVissible => !prevpassVissible)}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question