Code
Result

Component lifecycle

We can add hooks that are called during different moments at component rendering process:

  1. Added event: when a component is added into another
  2. Mount event: before the rendering of sub components
  3. 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)