dfalling

dfalling

Colocated hooks not including hook name

I’m trying to move to colocated hooks following the LiveView 1.1 Changelog.

I think I made all the necessary changes, but when my colocated hooks compile, they’re named simply ModuleName. The hook name is nowhere to be seen. Did I miss a crucial step of the migration, or is there something else I’m doing wrong?

Example hook:

defmodule IdoWeb.EmojiComponents do
  use Phoenix.Component

  alias Phoenix.LiveView.ColocatedHook

  def input(assigns) do
    ~H"""
    <span>
      <input
        id={@id}
        phx-hook=".EmojiInput"
      />
      <script :type={ColocatedHook} name=".EmojiInput">
        import { createPopup } from "@picmo/popup-picker";
        export default {
          mounted() {
          const input = this.el;

          const picker = createPopup(
          //...

Console error:

unknown hook found for “IdoWeb.EmojiComponents.EmojiInput”

Build directory:

_build/dev/phoenix-colocated/ido
├── IdoWeb.EmojiComponents
│   └── 20_stqqlse4fjjmkwaxmhvwqdkgdu.js

Thanks!

First Post!

RomainT

RomainT

Hi!

Same issue here in production. Did you find a solution?

Thanks!

Most Liked

steffend

steffend

Phoenix Core Team

You need to ensure that:

  1. You’re importing the colocated hooks in your app.js
import {hooks as colocatedHooks} from "phoenix-colocated/dayzee"
  1. When you’re building for production `mix compile` needs to run before `mix assets.deploy`

Try to read the `20_stqqlse4fjjmkwaxmhvwqdkgdu.js` file you’ve shown in your output. You should see the hook name in that file.

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement