phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
315 stars 90 forks source link

Changes to Functional Components not reloading correctly #120

Closed soullpoint closed 2 years ago

soullpoint commented 2 years ago

Hi there,

I’m seeing an issue where changes to functional components aren’t being reflected automatically until a refresh, or if I change other content on the page that is using the component.

For instance, I have a simple container:

defmodule Card do
  use Phoenix.Component

  def card(assigns) do
    ~H"""
    <div>
      <%= render_slot(@inner_block) %>
    </div>
    """
  end
end

This renders as expected on a page like so:

<Card.card>
  <div>Test Content</div>
</Card.card>

When I modify the functional component, e.g. to add a class to add the styling for the card, the page seems to refresh but the Card component is not updated to reflect the new style. However, if I modify the “inner block” content, e.g. the “Test Content” text, then the page is refreshed and the component changes come through.

Is this expected behaviour, or am I doing something wrong? (Note that this is not on a LiveView page, just a simple view)

Thanks

soullpoint commented 2 years ago

This is on Phoenix 1.6, LiveView 0.17, Elixir 1.12

soullpoint commented 2 years ago

https://elixirforum.com/t/phoenix-functional-components-and-hot-reloading/44043/2

My apologies, misunderstanding of how things work. Didn't realise the list was explicitly defined, assumed it was watching all .*ex files everywhere.