Skip to content
Discussion options

You must be logged in to vote

Hey @jacobdaddario, great question! I think I can answer some of this.

I'm fairly confident components do create their own view_contexts. This helps the library to be as fast as it is, but also gives some view helpers unexpected issues, like form_with. There's experimental support for the global view context, which would come from the view in which you're rendering components.

The reason why the method signature on initialize is a bit different is likely because instances of ViewComponent::Base respond to render_in. When you call render MyComponent.new, that's calling render_in on the instance of MyComponent and passing in the view context, if my understanding of it is correct.

To answer …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jacobdaddario
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants