Let's say I have an effect hook with a Person dependency that follows the schema Person: {name: string, age: number}. My effect hook for this Person dependency currently looks like this:
useEffect(() => {
if (person.name === 'Mike') {
doSomething()
}
if (person.age > 21) {
somethingElse()
}
}, [person])
Would it be valid code to separate this logic into their own effect hooks with the same dependencies:
// effect that handles any logic for a person's name
useEffect(() => {
if (person.name === 'Mike') {
doSomething()
}
}, [person])
// effect that handles any logic for a person's age
useEffect(() => {
if (person.age > 21) {
somethingElse()
}
}, [person])
I'm trying to separate unrelated code from each other in some of my components, and I'm wondering if this would be considered an anti-pattern or if it could result in unwanted issues?