Programming Phoenix LiveView B10: wrong arguments number in RatingLive.Show.stars (page 220)

In PentoWeb.RatingLive.Index.product_rating/1
function, there is a call to <RatingLive.Show.stars rating={rating} product={@product} />
. Later on, the function is referenced as having the only argument:
with the yet-to- be-built Show.stars/1 component…
what is in line with the defined later function:
defmodule PentoWeb.RatingLive.Show do
use Phoenix.Component
use Phoenix.HTML
attr :rating, :any, required: true
def stars(assigns) do
~H"""
<div>
<%= @rating.stars
|> filled_stars()
|> Enum.concat(unfilled_stars(@rating.stars))
|> Enum.join(" ")
|> raw() %>
</div>
"""
end
...
VS Code even displays a warning about it.
Later, on page 224, the call is correct though:
<Show.stars rating={rating} />
One more point regarding defining an alias for alias PentoWeb.RatingLive.Show
on page 224:
Make sure to alias the module in survey_live.ex like this
PentoWeb.RatingLive.
First, the name of the module is not wrong (survey_live.ex
) and should rather be RatingLive.Index
. In this case, as alias PentoWeb.RatingLive
being already aliased (defined on page 218), the correct module to be aliased would be alias PentoWeb.RatingLive.Show
, and alias PentoWeb.RatingLive
should be removed.
Popular Prag Prog topics










Other popular topics









Latest in PragProg
Latest (all)
Categories:
My Saved Portals
-
None saved yet
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /flutter
- /c-plus-plus
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /vuejs
- /nim
- /emacs
- /nerves
- /elm