-
I couldn't find a good example, so help is greatly appreciated I have a simple component that has some required params: # frozen_string_literal: true
class Shared::Navbar::Avatar::Component < ApplicationViewComponent
option :current_user
option :resource_name
option :avatar_size, default: proc { 40 }
def user_signed_in?
current_user&.user_signed_in? || false
end
def sign_in_path
new_session_path(resource_name)
end
end This is the preview code I am using based on the default generator: # frozen_string_literal: true
class Shared::Navbar::Avatar::Preview < ApplicationViewComponentPreview
def default
render_component(Shared::Navbar::Avatar::Component.new(current_user: Member.new, resource_name: :member))
end
end Whenever I try to preview the component I am getting the following error, not sure how to use the default preview template(even if it's possible tbh) once I have some required params
Not sure what I am doing wrong, or what I need to change The component works outside the preview, on the app code... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It seems that there is some problem with I believe, the exception is raised when we try to build a default component instance here: The question is where do we lost the |
Beta Was this translation helpful? Give feedback.
It seems that there is some problem with
render_component
method.I believe, the exception is raised when we try to build a default component instance here:
view_component-contrib/lib/view_component_contrib/preview/base.rb
Line 50 in d96e3b7
The question is where do we lost the
component
passed to therender_with_template
method along the way? Only debugging could help here 🤷♂️.