DEV Community

[Comment from a deleted post]
Collapse
 
eugbyte profile image
Eugene

what is the main difference between useEffect and useIonViewWillEnter? If I want to load the data on page load, can i just use useEffect over useIonViewWillEnter?

Collapse
 
daviddalbusco profile image
David Dal Busco

useIonViewWillEnter is an Ionic custom React hook that fires when the component routing to is about to animate into view - e.g. in other words "when you navigate from page a to b and b is about to enter".

useEffect is a basic React hook that either runs after the render is committed to the screen or can conditionally runs - in other words "a function that starts according the conditions you define - i.e. can starts on state mutation".

If I want to load the data on page load, can i just use useEffect over useIonViewWillEnter?

sure, both works depending of the use case