Code
Result
Component lifecycle
We can add hooks that are called during different moments at component rendering process:
- Added event: when a component is added into another
- Mount event: before the rendering of sub components
- Mounted event: after the rendering of sub components
The Component class has 3 methods for registering callbacks for these events:
added(callable $callback)
mount(callable $callback)
mounted(callable $callback)