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

[README] Expand render-prop doc #151

Merged
merged 1 commit into from Aug 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -398,18 +398,19 @@ The examples given for each prop use breakpoint definitions as defined in the
above ‘Setup’ section.

If you would like to avoid the underlying div that is generated by `<Media>` and
instead use your own element, use the render-props form:
instead use your own element, use the render-props form but be sure to **not**
render any children when not necessary:

```tsx
export const HomePage = () => {
return (
<>
<Media at="sm">Hello mobile!</Media>
<Media greaterThan="sm">
{(mediaClassNames) => {
{(mediaClassNames, renderChildren) => {
return (
<MySpecialComponent className={mediaClassNames}>
Hello desktop!
{renderChildren ? "Hello desktop!" : null}
</MySpecialComponent>
)
}}
Expand Down