Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic How it Works docs #2239

Merged
merged 8 commits into from
Mar 31, 2025
Merged

add basic How it Works docs #2239

merged 8 commits into from
Mar 31, 2025

Conversation

joelhawksley
Copy link
Member

Closes #899

@joelhawksley joelhawksley force-pushed the 20250324-how-it-works branch from c290b11 to b13b6bf Compare March 25, 2025 22:33

### At component instantiation

ViewComponent does not perform any actions at component instantiation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth calling out that the user provided initializer runs?

Copy link
Contributor

@khiga8 khiga8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀


### At render

When a ViewComponent is passed to `render`, Rails calls `render_in`, passing the current [ActionView::Context](https://api.rubyonrails.org/classes/ActionView/Context.html). `ActionView::Context` is used to provide access to the current controller, request, and helpers, which is why they cannot be referenced until a component is rendered.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha!

@joelhawksley joelhawksley merged commit 68b7f7c into main Mar 31, 2025
23 checks passed
@joelhawksley joelhawksley deleted the 20250324-how-it-works branch March 31, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add lifecycle diagram to documentation
3 participants