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

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New

We're in Beta

About us Mission Statement