I have some question while working with React.js. Say we have those useEffects that have the same dependencies inside some a.jsx:
// a.jsx
const Main = () => {
useEffect(() => {
console.log(1);
}, []);
useEffect(() => {
console.log(2);
}, []);
return <p>asdf</p>
}
In a b.jsx, I've gathered functions to have one useEffect, like below:
//b.jsx
const Main = () => {
useEffect(() => {
console.log(1);
console.log(2);
}, []);
return <p>asdf</p>
}
What is the different? Which one is the best practice?