What is the best practice to use React.JS useEffect hook when listening for multiple states change
first:
useEffect(() => {
if ( first ) {
// do the stuff for first state changes
}
if ( second ) {
// do the stuff for second state changes
}
})
second:
useEffect(() => {
// do the stuff for first state changes
}, [first])
useEffect(() => {
// do the stuff for second state changes
}, [second])
and what are the pros and cons between these two methods?