Alex Korban recently wrote an article called “Thoughts on Elixir, Phoenix and LiveView after 18 months of commercial use”, where he mentions that he avoids using live components whenever possible.
Live components are best avoided if possible, in my view.
There is a discussion of his article on Hacker News. Here Jose Valim agrees with him on his point about live components.
You are 100% correct on functional components vs live components. I will make it clearer in the docs the former should be preferred
The live component docs indeed include a short section about when to use functional components or live components.
Generally speaking, you should prefer functional components over live components, as they are a simpler abstraction, with a smaller surface area. The use case for live components only arises when there is a need for encapsulating both event handling and additional state.
However, I still don’t fully understand the rational behind choosing the one or the other.
For example, what does it mean for something to have a smaller surface area, in the context? And why is smaller better?
And why should live components exclusively be used when there is a need for event handling AND additional state?
What are the (hidden) costs of using live components, that make them something to avoid?
One reason I have been used live components is to make my code simpler to understand and easier to reason about, by encapsulation event handling and state. However, in some cases my code did not improve as much as I expected in that regard, partly because of the extra message handling between the root live view and the live component.