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
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
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
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Marked As Solved- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Nicd
Is
def componentsin HydroplaneWeb usingview_helpers()also? Then you’re running into a circle when compiling: view_helpers → import HydroplaneWeb.Components.Shared.Button → use :components → view_helpers.Also Liked
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.krstfk
Can you share your button module?
krstfk
That’s what I think as well.
Last Post!
elt547
In this case, how can I make all the other view helpers easily available in the component modules if I’m doing
use Phoenix.Component? It seems likeuse HydroplaneWeb, :componentis the expected usage in phoenix as of right now.Also should this be the same for
use HydroplaneWeb, :live_componentanduse Phoenix.LiveComponentand the others? Will there be another way to share code between different component modules?Lastly, is somebody able to explain exactly why the circular dependency was creating that error?