I’ve been building an app with phoenix liveview for 3 months. Although it’s not a big application, but one is already running in production. Two are in development, we’ll launch those in 3 months more or less.
I’m very familiar with node.js and react and I trying to switch to phoenix liveview. Server side rendering on React is pretty tough for small team. That’s the main reason why we switched to liveview. React is generally good except SSR.
LiveView has excellent concept, but lifecycle methods are pretty difficult to handle. When you visit a website [mount/3](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#c:mount/3)
always called twice. And that makes browser render twice, leading browser to “blink”.
defmodule XWeb.ShowLive do
alias X.Project
mount(params, session, socket) do
data = Project.list_items()
{:ok , assign(socket, :data, data)}
end
end
This causes re-rendering when socket is connected. So I found an answer and it doesn’t actually solve the problem. I want my app partially functional without websocket and also SEO friendly. To do that it seems “blink” is inevitable due to mount called twice separately with GET request and socket connection.
I’m new to elixir and phoenix. So this might sound like dumb. It would be good to separate mount and socket connection and assigns can live in browser session or indexdb?