What's the difference between a parent and child liveview

When reading the documentation on Phoenix.Component — Phoenix LiveView v0.20.17, it says it can be used to render child liveviews inside regular liveviews.

But when I start testing this I run into this error: handle_params/3 is not allowed on child LiveViews, only at the root. The documentation on handle_params (Phoenix.LiveView — Phoenix LiveView v0.20.17) doesn’t say anything about that though.

So I’m wondering:

  1. why handle_params is not allowed?
  2. are there any other differences between a root and child liveview. I originally thought that there would be no differences as I couldn’t find any documentation on differences.

handle_params only runs in a root LV, which is router mounter (using the live macro in the router).

The current url of a page is a singleton value, so all things related to that are serialized through such a root LV.

4 Likes