Lifecycle Callbcaks

With the concept of web app routing, we deal with each page context in a period of its lifecycle, which starts from pre-invoking the request to un-mounting its content. And we provide serveral callbacks in certain points of each lifecycle to let you control the whole page context flow.

componentWillMount

This function is invoked only once, which is after the component instance has been initialized.

  • You can restore the last visited URL from cookie at this point.

componentWillUnmount

This function is invoked only once, which is before the page is going to redirect to another page. The redirect-to page's URL is passed as the argument.

  • You can evaluate whether to redirect to another page. If you return false in the function, it will not redirect.

componentWillRoute

This function is invoked before the AJAX request is made.

  • You can modify the AJAX url. For most cases, you don't need to, but in some cases that you may want add an extra param to tell the controller to return the pure partial string.
  • You can show a loading animation at this point.

If you return false in the function, no AJAX request will be made, and this routing flow for current URL will end.

componentFailRoute

This function is invoked when the AJAX request failed.

componentWillUpdate

This function is invoked before updating the host page content with the AJAX returned html string

  • You can modify the content string before it is used to update the host page.

If you return false in the function, no update will be made, and this lifecycle will end.

componentDidUpdate

This function is invoked after the host page content has been updated to the returned AJAX request.

componentFailUpdate

This function is invoked when host page content has failed updating its content. Mostly it is because there is some JavaScript errors thrown out in the inline script of the embeded page.


componentWillClickLink

This function is invoked when a link is clicked in the embeded page.

componentWillSubmitForm

This function is invoked when a form is about to be sumbitted in the embeded page.