-
-
Notifications
You must be signed in to change notification settings - Fork 867
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
Changed passing children by props to nest between tags in docs #754
Conversation
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.
Thanks! I agree passing children as actual children instead of a prop is better. I just have some nits about spacing.
Codecov ReportPatch and project coverage have no change.
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #754 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 754 754
=========================================
Hits 754 754 ☔ View full report in Codecov by Sentry. |
Thanks for the reviews. I have made the suggested changes. |
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.
I'm cautious about this.
Yes as a general react practice, using nesting over the children
prop is ideal.
That said, JSX spacing rules and template string spacing rules inside JSX are a frequent source of confusion for new adopters https://github.com/remarkjs/react-markdown/issues?q=is%3Aissue+JSX+is%3Aclosed
I'd lean against making this change.
I think it will cause more confusion than it clarifies.
But will not block the PR if other maintainers feel strongly otherwise.
If we don’t want this, I think we should rename the prop to something else, e.g. |
I don't think it necessitates a major rework of the API. We could leave the docs as-is and let adopters choose which syntax they prefer. To pre-emptively answer the question: "could we document the rules of JSX next to the example?" |
Did y’all see #749 (comment)? I think people are going to try to pass children whether it works or not. As “text” inside the component, or as a sole expression inside the component. The main similar project to this, Theoretically, we could throw on that. Or we could ignore it and support another field. I don’t prefer those over the current, sole, The differences between I also mostly agree with Christian! (only point that I think we can use one style in the examples, so people copy the nicest one, where currently 2 are shown) I also think the ESLint rule is wrong: it’s good to use actual things in actual children normally, sure, but passing as a prop is useful in legitimate cases. |
Used one style in the docs: |
Initial checklist
Description of changes
Some of the examples mentioned in the readme are passing children as props which gives a ESLint error of
react/no-children-prop
on Next.js 13 with ESLint configuredUpdated the examples to nest child component between the opening and closing tags.