Is it possible to share functional components between dead and live views?

Hi! Before Phoenix 1.6 got released I read articles stating that sharing functional components between dead and live views is finally going to be possible. I saw there’s this Phoenix.Component but it seemed to me, and a look at the code confirmed it, that these new functional components are LiveView-only. Am I mistaken? Is there any way to share components?

yes, if you want to use functional components, you have to bring live_view in. Those functional components are then usable in dead and live views. But keep in mind, that functional components are stateless ones.

hope this helps

1 Like