Skip to content

Commit

Permalink
Merge pull request #151 from artsy/expand-render-prop-doc
Browse files Browse the repository at this point in the history
[README] Expand render-prop doc
  • Loading branch information
damassi committed Aug 24, 2020
2 parents 517a620 + 7034647 commit 7532fdd
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 7532fdd

Please sign in to comment.