const [messageCount, setMessageCount] = useState(0)
const [username, setUsername] = useState('Andres')
...
useEffect(
() => {
console.log(`Hello ${name}, you have ${count} unread messages`)
},
[name, count]
)
In a scenario like the above, where the second argument of useEffect
has more than one item, and they're basically values. How does it differentiate each item ?
if at a given time, name = 'Andres'
and count = 10
, and moments later count = 20
How does useEffect
decide how to compare items:
'Andres' === 10
or 10 === 20
?