Closed dpaluy closed 3 years ago
@dpaluy Could you try render_component(Button::Component.new() { "Welcome!" })
? I think I had an issue a while back related to ViewComponent where the block wasn't properly passed in as child content unless doing Component.new() { "child content" }
. Could be mistaken though and it's unrelated.
What's your version of view_component
gem?
And try the @thomasklemm's suggestion.
Following @thomasklemm guide, I debug this issue and found that render_component
doesn't have a block attribute.
I solved this issue by using a render
instead
https://github.com/github/view_component/blob/main/lib/view_component/preview.rb#L10
Example:
render(Button::Component.new) do
"Welcome"
end
@palkan my View Component version: 2.40.0
I want to render a block content
render_component Button::Component.new { "Welcome!" }
But the
content
isnil
. The original ViewComponent can render a content properly.Is it a bug, or there is a different way to render the
content
?Environment
Ruby Version: ruby 3.0.2p107 Rails: 7.0.0.alpha2 View Component version: 2.40.0 View Component Contrib Version: 0.1.0