# Dynamically change Live Layout

**URL:** <https://forum.elixirforum.com/t/dynamically-change-live-layout/66302>\
**Category:** Questions\
**Tags:** phoenix, liveview, layouts, live-view\
**Created:** [September 25, 2024, 5:43pm UTC](https://forum.elixirforum.com/t/dynamically-change-live-layout/66302 "2024-09-25T17:43:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sodapopcan](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/32/34668_2.png) [@sodapopcan](https://forum.elixirforum.com/u/sodapopcan)\
**Post date:** [September 25, 2024, 7:20pm UTC](https://forum.elixirforum.com/t/dynamically-change-live-layout/66302/2 "2024-09-25T19:20:55Z")

</div>

Hi and welcome to the forum!

One thing you can do is in stead of a live component, use a function component along with [`on_mount`](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#on_mount/1) and [`attach_hook`](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#attach_hook/4). You would do the initial logic to populate the list in `on_mount` as well as attach a `handle_info` hook to your LiveViews. The problem with this solution is that it won’t work in dead views if you have any of those, although it doesn’t sound like your current implementation would either so this might work for you.

You can use `on_mount` in your router to avoid having to do it in every LiveView.

---

_[View the full topic](https://forum.elixirforum.com/t/dynamically-change-live-layout/66302)._
