# `Soundcheck.Check.Warning.LiveViewCallbackInComponent`
[🔗](https://github.com/leonqadirie/soundcheck/blob/v0.1.0/lib/soundcheck/check/warning/live_view_callback_in_component.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `high` and works with any version of Elixir.

## Explanation

Flags LiveView callbacks defined in a LiveComponent: `mount/3`,
`handle_params/3`, `handle_info/2`, `handle_call/3`, `handle_cast/2`,
and `terminate/2`. A LiveComponent runs in its parent LiveView's
process and LiveView never calls these on it, so the code is dead.
`send(self(), msg)` from a component reaches the parent's
`handle_info/2`, not the component's.

Before:

    # in a LiveComponent
    def handle_info({:saved, post}, socket), do: {:noreply, assign(socket, :post, post)}

After:

    # in the parent LiveView
    def handle_info({:saved, post}, socket) do
      send_update(MyAppWeb.PostComponent, id: post.id, post: post)
      {:noreply, socket}
    end

A function another module calls on the component, such as a parent
that delegates `handle_info/2` to it, does not count as dead. The
compiler already warns when the function carries `@impl true`.

Confidence: high. Tier: syntactic (works without compiling).

## Check-Specific Parameters

Use the following parameters to configure this check:

### `:excluded_paths`

  Paths to skip (atoms, binaries as path segments, or regexes).

*This parameter defaults to* `[~r/\/test\//, "test"]`.

### `:strict`

  Unused.

*This parameter defaults to* `false`.

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
