View components as Containers & Components in a React kind of way #502
Unanswered
pinzonjulian
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey!
I've been playing with the idea of using View components as a way to prepare data for other components in a view, similar to how React uses Containers to prepare data for idempotent Components.
In the following example:
ProdutsGridContainer
has the responsibility of grabbing all the data using any means necessary (ActiveRecord for example).ProdutsGridContainer
's test isn't focused on the actual HTML renderredCardComponent
is idempotentCardComponent
doesn't have the need to query any more data. It receives primitives such as strings, integers etc.CardComponent
's tests are super light because they don't need any database access.Have you encountered this need in your projects? How do you feel about this pattern in Rails?
Beta Was this translation helpful? Give feedback.
All reactions