-
Notifications
You must be signed in to change notification settings - Fork 62
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
Allow omitting the component name with props on render #199
Conversation
Linter fails, but I fixed it in other PRs, so will just wait 😂 |
Oh that's nice. Much cleaner than the useless |
Yup, used that a lot with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, I'll get some things merged!
lib/inertia_rails.rb
Outdated
if component.is_a?(Hash) && options[:props].nil? | ||
options[:props] = component | ||
component = true | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we couldn't/shouldn't put this logic in the renderer file? Its initialize method is already figuring out how to handle the (overloaded) component argument. Might be nice for Future Us to have the argument munging logic in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check for this condition and raise a helpful error?
render inertia: { users: User.all }, props: { just_kidding: 'about that users prop!' }
As it is I think this would fail as a white screen of death on the frontend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check
I think you could do this already to get automatic component paths with explicit props, right? render inertia: true, props: { some: 'stuff' } That said, this does look nicer: render inertia: { some: 'stuff' } I don't love that this What if we deprecate the render inertia: {} in the case where you want the automatic path resolution but don't need to send props. |
b2aab22
to
2b738cd
Compare
2b738cd
to
380f9dc
Compare
@bknoles is there anything holding us from merging this one? |
Sorry for the delay! I was on the fence on two things:
Coming back to it today, neither is important enough to me to delay merging |
This PR improves the automatic component name functionality, with these changes we can now render a page like this: