Closed jrson83 closed 2 years ago
What is the purpose of
willUnmount()
?
This can be useful for clean up. It is invoked immediately before a component is unmounted. You can cancel network requests and invalidate timers, remove event listeners or subscriptions. It allows for transitions, so you can add classes at that point, add a listener for when the CSS event ends. You can possibly make the willUnmount()
async, so it will wait with unmounting when the CSS animation is finished and you return from the function.
Reference Issues/PRs
None
What does this implement/fix?
To create new/more opportunities for developers, the following methods have been added:
willUpdate()
didUpdate()
Todo
didUpdate()
, to give the opportunity for conditionally actions and makestate
more reactiveThe Nano JSX Component Lifecycle
Mounting
These methods are called in the following order when a class component is created and rendered:
Updating
When calling
this.update()
on a class component, these methods are called in the following order:Unmounting
This method is called when a class component gets removed/unmounted:
Thanks to Robert Boes!