i'm woundring if is it OK to write all the logic inside a useEffect react hook or to create a function and call it inside the useEffect.
First way
useEffect(()=>{
// code logic
},[dependency array])
Second way:
const toDoFunc = ()=>{
// code logic
}
useEffect(()=>{
toDoFunc()
},[dependency array])
i'm really confused cause i tested both approaches in matter of time execution(using the console.time && console.timeEnd functions ) and found that sometimes the first approache is faster and sometimes the second one is faster.