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>`
CodePudding user response:
we use == when we want to check the value of the variable equal to something. instead use =
`<TouchableOpacity
onPress={() => {
notifications.read = true
console.log(notifications.read)
}}
CodePudding user response:
const sample = () => {
const [notifications, setNotifications] = useState({read:false});
const handle_notif_status = () => {
let new_status = {read:true};
setNotifications(new_status);
}
}
strong text
now on your onPress method call handle_notif_status