I want to change a value coming from API and its Boolean in React Native but even when I click on it the value is still false, but I want it to become notifications.read true on Press
Here is my code
`<TouchableOpacity
onPress={() => {
{notifications.read == true}
console.log(notifications.read)
}}
>
<Text style={{
textDecorationLine: 'underline',
fontSize: 14,
color: Colors.primaryColor,
lineHeight: 18,
letterSpacing: 0.1,
}}>
</Text>
</TouchableOpacity>`
3
Answers
we use == when we want to check the value of the variable equal to something. instead use =
strong text
now on your onPress method call handle_notif_status
The
{}
in{notifications.read == true}
is redundant and also the==
makes this statement a comparison. Change this line tonotifications.read = true
to fix.