Undefined function live_flash/3 within component

I want to handle flash messages in a component:

defmodule ExampleWeb.FlashMessageComponent do
  use ExampleWeb, :live_component

  def render(assigns) do
    ~L"""
    <%= live_flash(@flash, :info) do %>
      <h3 class="text-sm font-medium text-green-800">
        <%= live_flash(@flash, :info) %>
      </h3>
    <% end %>

    <%= if live_flash(@flash, :error) do %>
      <h3 class="text-sm font-medium text-red-800">
        <%= live_flash(@flash, :error) %>
      </h3>
    <% end %>
    """
  end

end

I call this component in lib/example_web/live/page_live.html.leex with

<%= live_component @socket, FlashMessageComponent, flash: @flash, id: 1 %>

But this results with the following error:

##### CompileError
# lib/example_web/live/components/flash_message_component.ex:6: 
undefined function live_flash/3

I don’t even understand why it tries to call live_flash/3 when I call live_flash/2. Where am I doing a mistake? How can I fix it?

You missed an if in the 1st line

Thanks! What an embarrassing mistake.