Share the post

Hello All, As we are already familiar with Ionic 4 lifecycle events in ionic. Let’s recall this event again. These methods are really useful when you are working with actual applications.

LifeCycle Events In Ionic 4 – React :

ionViewWillEnter :
This method is called every time. This method is good to initialize the data. Just before entering a View, this method is called.

ionViewDidEnter :
After entering a View this method calls. When the user can able to see the view. As soon as the user was able to view the page this event fires.

ionViewWillLeave :
This event fires when users are able to leave the view.

ionViewDidLeave :
This event fires when the user completely leaves the view.

Although apart from this we have to know about react also having its own lifecycle

The Basic Events in react is as follows :

componentDidMount () :

This method fires immediately when the component is mounted. This method is good to initialize the data, Also to call a network HTTP request this method normally used. This method is used to call when subscribing to any data. setState() can also be called immediately.

componentDidUpdate() :

This method calls when the update of data occurs. Please remember that this is not called when the view first renders. This method is also good to call network requests.

componentWillUnmount() :

This method fires when users about to leave the view or destroy the view. This method is used to unsubscribe the data. This is not a place to call setState() as a component will never re-rendered.

So, remember the above LifeCycle method which React JS offers. But while using a framework like Ionic you did not worry about calling the above three basic methods.

As explained earlier ionic lifecycle will take care of it. Internally ionic calls the react lifecycle events.

Leave a Comment