elt547
I’m trying to get my function components available in all of my views. My shared components are in there own files under /live/components/_shared. And I have one shared.ex file available under /live/components/shared.ex. I don’t know enough about macros in elixir yet.
This is what it looks like:
defmodule HydroplaneWeb.Components.Shared do
alias HydroplaneWeb.Components.Shared
defmacro __using__(_opts) do
quote do
import Shared.{Button, Card, Dropdown, Lists, Modal}
end
end
end
But when I use it from my view_helpers() it is giving me the error Shared.Button.module_info/1 is undefined (function not available).
defp view_helpers do
quote do
# ..................
use HydroplaneWeb.Components.Shared
end
end
I have tried a few different configurations but just know I’m missing something basic. How can I get this working so that all of my function components are available in my liveview templates? Also what key concept am I misunderstand so I can avoid the same mistake in the future?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Do we have maintainer of absinthe-graphql/dataloader here? We have a PR that we’d like to merge to the library. Relatively small additive...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
The
alias HydroplaneWeb.Components.Sharedyou have at the top of the file is not in the same scope as yourimport Sharedline. You can see this in the error message in that it isShared.Button.module_info/1notHydroplaneWeb.Components.Shared.module_info/1.You should either make the import fully qualified eg
import HydroplaneWeb.Components.Shared.{Button, Card, Dropdown, Lists, Modal}or add the alias inside thequote. I’d recommend just making it fully qualified so you don’t inject an alias into the other module.elt547
I tried getting rid of the alias and making the module fully qualified inside of
__using__/1but I’m getting the same error. I also tried putting theimport HydroplaneWeb.Components.Shared.{Button, Card, Dropdown, Lists, Modal}directly inside of the quote block in view_helpers.benwilson512
Can you show how you are calling these components?
krstfk
My guess is that you might have a typo somewhere in your
elt547
There’s no typo, and it happens with more than just the Button module. If I change it to include the individual modules it happens with all of them.
elt547
Of course, I’m trying to call them like this as function components:
benwilson512
Is the error you get a runtime or compile time error? Is there a stack trace or more information you can provide?
What is the exact error you get if you do
elt547
When I try to start the server I get this:
krstfk
Can you share your button module?
elt547
Sure, it’s pretty basic.